Я пытаюсь научиться обрабатывать текст на ассемблере.Я не уверен, почему моя последняя функция [__asm void my_uppper_first_last (char * str)] работает.
Только у этой функции есть проблема.
__asm void my_uppper_first_last(char *str)
{
cap_first
LDRB r1, [r0] ; Load byte into r1 from memory pointed to by r0 (str pointer)
CMP r1, #'a'-1 ; compare it with the character before 'a'
BLS cap_next ; If byte is lower or same, then skip this byte
CMP r1, #'z' ; Compare it with the 'z' character
BHI cap_next ; If it is higher, then skip this byte
SUBS r1,#32 ; Else subtract out difference to capitalize it
STRB r1, [r0] ; Store the capitalized byte back in memory
cap_next
ADDS r0, r0, #1 ; Increment str pointer
CMP r1, #1 ; Was the byte 1?
BNE cap_load ; If not, repeat the loop
B cap_last
cap_load
LDRB r1, [r0] ; Load byte into r1 from memory pointed to by r0 (str pointer)
B cap_next
cap_last
LDRB r1, [r0] ; Load byte into r1 from memory pointed to by r0 (str pointer)
CMP r1, #'a'-1 ; compare it with the character before 'a'
BLS cap_exit ; If byte is lower or same, then skip this byte
CMP r1, #'z' ; Compare it with the 'z' character
BHI cap_exit ; If it is higher, then skip this byte
SUBS r1,#32 ; Else subtract out difference to capitalize it
STRB r1, [r0] ; Store the capitalized byte back in memory
cap_exit
ADDS r0, r0, #1 ; Increment str pointer
BX lr ; Else return from subroutine
}
int main(void){
const char a[] = "Hello world!";
char b[20];
my_strcpy(a, b);
my_capitalize(b);
my_lower_case(b);
my_uppper_first_last(b);
while (1);
}
Нет ошибки при перестройке,но когда вы выполните его, он застрянет на этой функции.
Заранее спасибо за помощь.