I used to compile my asm code with TASM (on winXP), but I had some problems, so now I use NASM (on Linux). This snippet shows what I'm trying to do:
(gdb) list 35 30 xor ecx,ecx
This looks right to me, but:
Breakpoint 1, main () at project1.asm:30 30 xor ecx,ecx (gdb) display (char) $al 1: (char) $al = 0 '\000' (gdb) display (char) $bl 2: (char) $bl = 0 '\000' (gdb) next 31 mov bl, ' ' 2: (char) $bl = 0 '\000' 1: (char) $al = 0 '\000' (gdb) count_spaces () at project1.asm:33 33 mov al,[esi] 2: (char) $bl = 0 '\000' 1: (char) $al = 0 '\000' (gdb)
I do not understand why al and bl not changed.
I'm sure my code is correct, but .. I think I missed some version of NASM? BTW compiled with
nasm -f elf -l project1.lst -o project1.o -i../include/ -g project1.asm
After compilation, I parsed the output and got:
80483ec: 31 c9 xor %ecx,%ecx 80483ee: bb 20 00 00 00 mov $0x20,%ebx 080483f3 <count_spaces>: 80483f3: 8b 06 mov (%esi),%eax 80483f5: 3d 00 00 00 00 cmp $0x0,%eax 80483fa: 74 0b je 8048407 <spaces_counted> 80483fc: 46 inc %esi 80483fd: 39 d8 cmp %ebx,%eax 80483ff: 75 f2 jne 80483f3 <count_spaces> 8048401: 41 inc %ecx 8048402: e9 ec ff ff ff jmp 80483f3 <count_spaces>
source share