ARM汇编 - code,以取代一个字符串的字符 [英] ARM assembly - code to replace character on a string
本文介绍了ARM汇编 - code,以取代一个字符串的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个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 ) ;
}
我必须做出一个手臂的程序,改变了E的字符串X,到目前为止,这是我所\\
I have to make an arm program that changes the 'e' on the String to 'x', so far this is what I have \
.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
这是虽然给我一个无限循环和我卡住了,谁能帮我找出问题出在哪里?
This is giving me an infinite loop though and I'm stuck, can anyone help me figure out where the problem is??
因此,这是我到目前为止,
So this is what i have so far,
.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注册表是空...
it runs but the character is never changed..., the output and the end is the same one as the input, for some reason, the a2 registry is null...
推荐答案
这行是完全错误的。
mov v3, a3 // change the character for the new character
这应该是有条件存储回字符串。
This should be a conditional store back into the string.
streqb a3, [a1, v1]
这篇关于ARM汇编 - code,以取代一个字符串的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文