Question: Write an ARM assembly language which accepts an integer and returns a string which is the hexadecimal representation of the integer. The signature of the

Write an ARM assembly language which accepts an integer and returns a string which is the hexadecimal representation of the integer.

The signature of the routine is:

char * int2hex( int conv ) ;

The input is a 32 bit integer. The output is a pointer to a character string of the format 0Xdddddddd. Do not suppress leading zeroes.

The C program is:

#include

#include

extern char * int2hex( int convert ) ;

int main( int argc, char * argv[] )

{

int convert = 1194684 ;

char * result ;

result = int2hex( convert ) ;

printf( "Integer to hex string: %s ", result ) ;

}

A string in C is terminated by a null byte (a byte of zero).

You will need to use the shift instructions. You need to separate the integer into 4 bit sections each representing the individual hex digits. These need to be turned into printable characters.

You need to adjust the resulting values for the digits A-F.

Use the strb instruction and an auto increment of 1 since you are storing bytes into memory.

Use the malloc library routine to obtain space for the character string (11 bytes: 2 for 0x, 8 for the hex digits, and one for the null byte).

Please provide comments next to the Assembly code, so I can understand how this is to be done. Here is an example of a previous assignment completed:

Write an ARM assembly language which accepts an integer and returns a

string which is the hexadecimal representation of the integer. The signature of

Thank you!

Question Write an ARM assembly function that replaces a specific character in a string with another and counts the number of times the replacement occurs. The function's signature is: int replace( char* str, char Ir, char rp) where char * str is the pointer to the character strng, char Ir is the char that needs replacing, and char rp is the replacement character. The C language program is: #include #include extern int replace( char*s, char Ir, char rp) int main int argc, char* argv]) int result char lr = 'e' ; char rp X' char str[]-"easy to replace" ; result= replace( str, Ir, rp ) ; result =replace( str, %sin", result, str) ; printf( "%d changes, %s ", result, str ) ; exit( 0)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!