Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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
#include

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

int main( int argc, char * argv[] )
{
char tosub[] = "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 bl malloc. 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.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9616332

Have any Question?


Related Questions in Computer Engineering

Suppose you are a manager in the it department for the

Suppose you are a manager in the IT department for the government of a corrupt dictator, who has a collection of computers that need to be connected together to create a communication network for his spies. You are given ...

Suppose a punched card has 80 columns and 12 rowsa if any

Suppose a punched card has 80 columns and 12 rows. (a) If any number of holes can be punched in the card, how many different cards can there be. If more convenient, you may give your answer in the form of an expression. ...

Salesthe sales department is in a unique position customers

Sales The sales department is in a unique position: customers seek out Thermo-Chem because it has cornered the market with virtually no competition except in the chemicals market. Therefore, only limited sales effort is ...

Patient patientid familyname givenname address suburb state

PATIENT (PatientID, FamilyName, GivenName, Address, Suburb, State, PostCode) DOCTOR (ProviderNo, Name) ITEM (ItemNo, Description, Fee) ACCOUNT (AccountNo, ProviderNo, PatientID, TreatmentDate) ACCOUNTLINE (AccountNo, Ite ...

Explain the risk of having hacking tools installed on your

Explain the risk of having hacking tools installed on your computer and why you should contact local law enforcement agencies before installing those tools.

Consider a valleyed array a1 2 middot middot middot n with

Consider a valleyed array A[1, 2, · · · , n] with the property that the subarray A[1..i] has the property that A[j] > A[j + 1] for 1 ≤ j (a) What is a recursive algorithm that takes asymptotically sub-linear time to find ...

Give examples of how dominos has adapted its global

Give examples of how Domino's has adapted its global marketing mix to meet the needs of local consumers. Are you their customer? If so, why?

What are some of the basic principles involved with

What are some of the basic principles involved with utilizing the ADT stack? What are some applications that could effectively utilize a stack?

Mary kate is a project manager in the it department for a

Mary Kate is a project manager in the IT department for a university. She has been asked to manage a project to create faculty intranet. The university has multiple campuses in various locations, and professors and other ...

Answer the following questions 1 suppose we want to

Answer the following Questions : 1. Suppose we want to transmit the message 1011101110 and protect it from using the CRC polynomial x 3 + x + 1. Use polynomial long division to determine the message should be transmitted ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As