flat assembler
Message board for the users of flat assembler.
Index
> Main > Counting 'X' and 'x' in string? |
Author |
|
revolution 02 Feb 2013, 08:41
I think you might want to use:
Code: movzx eax,byte[ecx+blah] Code: lea eax, [ecx + blah] Code: cmp byte[eax],88 Code: cmp byte[ecx+blah],88 |
|||
02 Feb 2013, 08:41 |
|
baldr 02 Feb 2013, 11:18
Or even cmp byte [ecx+blah], 'X'.
|
|||
02 Feb 2013, 11:18 |
|
TmX 02 Feb 2013, 14:29
@revolution
The program gets stuck if either "lea eax, [ecx + blah]" or "movxz eax,byte [ecx + blah]" is used @baldr That yields 0. Weird |
|||
02 Feb 2013, 14:29 |
|
revolution 02 Feb 2013, 14:35
Oh yeah. You'll have to add "inc ecx" in the addOne branch also.
That code needs to be rewritten, it jumps about too much and is difficult to follow. |
|||
02 Feb 2013, 14:35 |
|
AsmGuru62 02 Feb 2013, 15:43
Let me try:
Code: mov esi, bla cld xor eax, eax ; EAX=0 -- To load characters from 'bla' xor edx, edx ; EDX=0 -- To count 'x' and 'X' @@: lodsb ; AL<-[ESI] and ESI = ESI+1 test eax, eax jz .print_counter ; String ended with zero byte cmp al, 'x' je .count_me cmp al, 'X' jne @r .count_me: inc edx jmp @r .print_counter: ; ; ... print value in EDX here ; |
|||
02 Feb 2013, 15:43 |
|
TmX 02 Feb 2013, 15:47
@revolution
Still doesn't work. And why call "inc ecx" once again? And sorry for the spaghetti code. I'll try rewrite it |
|||
02 Feb 2013, 15:47 |
|
Picnic 02 Feb 2013, 16:15
TmX hi,
The program enters an infinite loop when it meets x or X because in that case the string index (ecx) is not updated. |
|||
02 Feb 2013, 16:15 |
|
TmX 02 Feb 2013, 16:55
Picnic wrote: TmX hi, Ah, yes you are right. Thanks. Now it works. |
|||
02 Feb 2013, 16:55 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.