Question: 1. Write a new subroutine in assembly to convert the upper-case letters to lower-case letter. 2. Write a new subroutine in assembly to convert only
1. Write a new subroutine in assembly to convert the upper-case letters to lower-case letter.
2. Write a new subroutine in assembly to convert only the first and last letters of a string to uppercase letter.
__asm void my_strcpy(const char *src, char *dst){
loop
LDRB r2, [r0]
ADDS r0, #1
STRB r2, [r1]
ADDS r1, #1
CMP r2, #0
BNE loop
}
__asm void my_capitalize(char *str){
cap_loop
LDRB r1, [r0]
CMP r1, #'a'-1
BLS cap_skip
CMP r1, #'z'
BHI cap_skip
SUBS r1,#32
STRB r1, [r0]
cap_skip
ADDS r0, r0, #1
CMP r1, #0
BNE cap_loop
BX lr
}
/*----------------------------------------------------------------------------
MAIN function
*----------------------------------------------------------------------------*/
int main(void){
const char a[] = "Hello world!";
char b[20];
my_strcpy(a, b);
my_capitalize(b);
while (1);
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
