Question
Write an ARM assembly function that takes a mixed case string and returns the string in all upper case characters. The input string to the
Write an ARM assembly function that takes a mixed case string and returns the string in all upper case characters. The input string to the function is immutable (cannot be changed). You must return a pointer to the new string.
To obtain a pointer to the new string you first need to determine the string length using the strlen function in the library routines. The input to the function is a pointer to a string in a1 and its output is the string length in a1. This number does not include the null byte sentinel at the end of the string so you should add 1 before the next step.
To obtain a pointer to the space for the new string use the malloc library routine. The input to the function is the number of bytes requested for the new space in a1. The output of the function is a pointer to the space requested in a1.
To change a lower case character to upper case change bit 5 in the ASCII character code to zero. For example to change a, 0x0110 0001, to A, 0x0100 0001, reset bit 5 (from the right starting the count at 0) to zero.
The C language program is:
#include
extern char * upcase( char * str ) ;
void main( int argc, char * argv[] )
{
char str[] = "This Is tHe strINg to Upper Case" ;
char * result ;
result = upcase( str ) ;
printf( "Original string: %s ", str ) ;
printf( "Upcased string: %s ", result ) ;
}
The input to the ARM assembly language function is a pointer to the first element of the string in register a1. Remember a character is 1 byte long. A string in C is terminated with a null byte (one equal to zero).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started