Write an arm subroutine which allocate memory for new string

Assignment Help Programming Languages
Reference no: EM1373160

Write an ARM subroutine which will extract a substring from a string. You will need to use the library routine malloc to allocate memory for the new string.

The subroutine signature is:

            char * mysubstring( char string[], int start, int end ) ;

 

where char string[] is the string to extract the substring from; it is passed into the ARM routine as a pointer in a1 to the first element of the character (byte) array,

int start is the first character to extract from the string to the substring; it is passed into the ARM routine as a value in a2,

int end is the last character to extract from the string to the substring; it is passed into the ARM routine as a value in a3.

The return is a pointer to the new string.

#include <stdio.h>

#include <stdlib.h>

extern char * mysubstring( char string[], intstart, int end ) ;

int main( intargc, char * argv[] )

{

            chartosub[] = "this is the string to substring" ;

            char * result ; /* pointer to new string */

 

            result = mysubstring( tosub, 12, 17 ) ;

            printf( "String: %s\nSubstring: %s\n", tosub, result ) ;

 

            exit( 0 ) ;

}

To use the library routine malloc you need to calculate the number of bytes of memory you are requesting, put that number in a1 and blmalloc. Upon return from the library routine a1 will have a pointer to the allocated memory.

You may assume that the start and end values are within the string and  malloc returns a proper pointer value.

Reference no: EM1373160

Questions Cloud

Capital budgeting decisions and utility rate decisions : If the expected returns for risk free asset and a risky asset are 4 percent and 17 percent respectively, what percentages of your money must be invested in risky asset and risk free asset, respectivel.
Design of the software : Report of the software design and implement the software as per the design, and demonstrate it
Multiple choice question on wacc : Brandon Corporation consists of two divisions of same size, and Brandon is 100% equity financed. Division A cost of equity capital is 9.8%, while Division B cost of equity capital is 14%.
Determine the risk premium and average risk premium : Here are stock market and Treasury bill returns between 1997 and 2001, Determine the risk premium on common stock in each year?
Write an arm subroutine which allocate memory for new string : Prepare an ARM subroutine which will extract a substring from a string and you will need to use the library routine malloc to allocate memory for the new string - CS252 Programming Assignment
Estimating cost of capital : Canyon Corporation has two divisions: Division A makes up 50% of the company, while Division B makes up the other 50%. Canyon's beta is 1.2.
Determine the project irr and cost of capital : Determine the project IRR and the cost of capital for the project? Does the accept reject decision using IRR agree with the decision using NPV?
Finding the arithmetic mean of returns : Assume you know that someone invested $1,500 in the Ec140 mutual fund 10-years ago, Now you learn that their balance in the fund has increase to $9,245.
Question based on expected profit : Suppose you know that there is a 40 percent probability that Microsoft will be selling for $22.50 three months from now and a 60 percent probability that it will be selling for $42.50.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write program which uses while loops to input two integers

Write the program which uses while loops to perform the following steps: prompt the user to input two integers: firstNum and secondNum.(firstNum must be less than secondNum.

  Write program to allow user to enter marks of students

Write a program that allows user to key in marks of students. The number of students is determined by the user at the start of the program.

  Design architecture of system to accept natural language

Using the generic model of a language processing system presented here, design the architecture of a system that accepts natural language commands and translates.

  Create e-r diagram for sell and buy of antiques

Create E-R diagram for following situation (state any assumptions you believe you have to make to develop diagram): XYZ Antiques buys and sells one-of-a kind antiques of all kinds

  Write a program that inputs number of hours worked

Write a program that inputs the number of hours worked and hoursly pay rat for employesand outputs their total pay.

  Differentiating client-side and server-side scripting

Understanding difference between client-side and server-side scripting is significant when developing interactive sites. When and why should you use client-side versus server-side scripting?

  Provide unoptimized-optimized prefix using recursive rule

Where the recursive rule uses concatenation of strings, so F2 is "ab", F3 is "aba". Note that the length of Fn is the nth Fibonacci number. Provide unoptimized and optimized ‘prefix' (fail) function for F7.

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Program to allot new value to first element of array

Write the single statement which assigns new value to first element of array. This new value must be equal to twice value stored in the last element of the array.

  Create-implement program which creates exception

Create and implement a program which creates an exception class called StringTooLongException, designed to be thrown when string is discovered that has too many characters in it.

  Create visual basic windows application

Create Visual Basic Windows application. Use following names for solution and project, respectively: Raise Solution and Raise Project.

  Write class called flight which represents airline flight

Draw and implement the class called Flight which represents an airline flight. It must contain instance data which represents airline name (String), flight number (int), and the flight's origin city (String).

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd