Hey, let's say i have a string "abcabc".
How would i check if the last char is "c", and if it's not, add it to the initial string?

Thanks.
Posted on 2003-07-01 05:39:46 by Ghirai
Here is a 'no frills' version:



.data
string db "abcabP",0

; [...snip...]
mov edi, OFFSET string
mov al, BYTE PTR [edi+5]
cmp al, "c"
je @F
mov BYTE PTR [edi+5], "c"
@@:
PrintString string


using vkim's debug to print string.

You can also use (.IF) and do a strlen or something to find the end of the string instead
of edi+5.

RobotBob
Posted on 2003-07-01 06:37:48 by RobotBob
How would i check if the last char is "c", and if it's not, add it to the initial string?

You mean add it to the end of thes tring or what?



lea edi, source
dec edi
@@:
add edi, 1
cmp byte ptr[edi], 0
jnz @B
cmp byte ptr[edi-1],'c'
jz @F
mov word ptr [edi-1], 'c'
@@:


Something like that I suppose.
Posted on 2003-07-01 07:08:57 by roticv
Yup, thanks.
Posted on 2003-07-01 10:43:09 by Ghirai