views:

414

answers:

1
.section .data

astring: .asciz "11010101"
format: .asciz "%d\n"

.section .text
.globl _start

_start:

xorl %ecx, %ecx

movb astring(%ecx,1), %al
movzbl %al, %eax

pushl %eax
pushl $format
call printf
addl $8, %esp


movl $1, %eax
movl $0, %ebx
int $0x80

Suppose I wanna break the .asciz string 1101011 and get it's first one. How do I go about it? The code above ain't working, it prints 49 or something.

+2  A: 

Change the conversion specifier for printf from %d to %c to print the character instead of its ascii value.

Robert Gamble
great, now I wanna get groups of three out of my 10i101010101 chain, how would I go about it? I tried changing the scale of movb astring(%ecx,1), %al to 3 and 2 and didn't work.
omgzor