What help with this Assembly language Subroutine, Basic Computer Science

Assignment Help:
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.

Related Discussions:- What help with this Assembly language Subroutine

10, constant key use for in calculator

constant key use for in calculator

Write a schema for the operation of ending a game, QUESTION 1 We need ...

QUESTION 1 We need to write Z specifications to record the information about passengers on board an aircraft. Here you are required to produce the specifications using appropr

What is the need for an intelligent website?, Problem Hanson websites a...

Problem Hanson websites are built to work for your business and are built on the concept of intelligent website. An intelligent website is more than just a brochure on the web.

CAI, What is CAI? Explain its pitfalls.

What is CAI? Explain its pitfalls.

Output design, Discuss the factors considered during output design

Discuss the factors considered during output design

Magnetic core memory, MAGNETIC CORE MEMORY: This type of memory is used...

MAGNETIC CORE MEMORY: This type of memory is used extensively in airborne digital systems, although integrated circuits are being developed with most modern aircraft systems.

Calories burned, Running on a particular treadmill you burn 3.9 calories pe...

Running on a particular treadmill you burn 3.9 calories per minute. design a program that uses a loop to display the number of calories burned after 10,15,20,25,30 minutes?

Database, Q1: ER modelling & logical design. An information system is requi...

Q1: ER modelling & logical design. An information system is required for an online auction site, based on the following speci?cation: Only registered users can use the site. Privat

Historical background of computers, Historical Background The br...

Historical Background The brief history of the growth of computers is given below: Abacus:   It was the first mechanical device developed approximately 3,000 year

Write Your Message!

Captcha
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