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

Concept of programming language, CONCEPT OF PROGRAMMING LANGUAGE: In o...

CONCEPT OF PROGRAMMING LANGUAGE: In order to communicate with other human beings, one needs some language or a medium. In the same way for solving problems, a programming  lan

Properties of Dictionary Keys, Dictionary values encompass no limitations. ...

Dictionary values encompass no limitations. They can be any random Python object, moreover standard objects or user-defined objects. Though, same is not true for the keys. There ar

Normalization, how we come to know about primary key,if more than ids gathe...

how we come to know about primary key,if more than ids gather?

Briefly explain the types of textures, Question 1 Describe the four compon...

Question 1 Describe the four components of light source Question 2 Briefly explain the types of textures Question 3 Explain the standard settings used to adjust th

C++, whats the out put of int main(){ int n=310; funcone(n); functwo(&n); ...

whats the out put of int main(){ int n=310; funcone(n); functwo(&n); cout return 0; } void funcone(intn) n=240; } void func two(intn*) { n=120; }

Hangman, Aim This assignment is intended to assess your skills in understan...

Aim This assignment is intended to assess your skills in understanding and interpreting a moderately complex problem, designing a solution to the problem and implementing the desig

What is the basic model of cpu structure?, As there are many variations i...

As there are many variations in architecture between the different kinds of CPU, we shall begin my looking at an easy model of the structure. The basic model consists of five part

Theory of computation, I define a restricted form of TMs M as follows. Give...

I define a restricted form of TMs M as follows. Given any input x on the tape of M, the initial portion of the tape that holds x is read-only and one-way. That is, M cannot write o

COMPUTER, DUNIYA KA AISA KONSA KOMPUTER HAI. JISME KEYBORD, MOUSE NAHI HAI?...

DUNIYA KA AISA KONSA KOMPUTER HAI. JISME KEYBORD, MOUSE NAHI HAI?

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