私はこのCドライバープログラムを持っています
#include <stdlib.h>
#include <stdio.h>
extern void subs( char *string, char this_c, char that_cr ) ;
int main(int argc, char *argv[] )
{
char this_c= 'e' ;
char that_c = 'X' ;
char orgstr[] = "sir sid easily teases sea sick seals" ;
subs( orgstr, this_c, that_c ) ;
printf( "Changed string: %s\n", orgstr ) ;
exit( 0 ) ;
}
String の 'e' を 'x' に変更するアーム プログラムを作成する必要があります。これまでのところ、\
.global subs
subs:
stmfd sp!, {v1-v6, lr} //string entry
mov v1, #0 //set index to 0
mov v2, #0 // set count to 0
loop :
ldrb v3, [a1,v1] // get the first char
cmp a2,v3 //compare char if its the same to the one that has to b chang
mov v3, a3 // change the character for the new character
addeq v2, v2, #1 //increment count
add v1, v1, #1 // increment index
cmp v3,#0 //end of string
bne loop
mov a1,v2 //return value
ldmfd sp!, {v1-v6, pc}
.end
しかし、これは私に無限ループを与えており、私は立ち往生しています。問題がどこにあるかを理解するのを手伝ってくれる人はいますか??
だからこれは私がこれまで持っているものです、
.global subs
subs:
stmfd sp!, {v1-v6, lr} //string entry
mov v1, #0 //set index to 0
mov v2, #0 // set count to 0
loop :
ldrb v3, [a1,v1] // get the first char
cmp a2,v3 //compare char if its the same to the one that has to b chang
moveq v3, a3 // change the character for the new character
addeq v2, v2, #1 //increment count
add v1, v1, #1 // increment index
cmp v3,#0 //end of string
bne loop
mov a1,v2 //return value
ldmfd sp!, {v1-v6, pc}
.end
実行されますが、文字は決して変更されません...、出力と最後は入力と同じです、何らかの理由で、a2レジストリはnullです...