I am writing a program to print out all the numbers from zero to 100. The only reason I am doing this is to test out printing out multiple digit numbers.
The problem th
This is my function to print the digits on stdout. It's in AT&T sorry ;)
movl , %eax
xor %ecx, %ecx # the counter
movl $10, %ebx
loop:
xor %edx, %edx
div %ebx # isolate the last digit, remainder in edx
add $48, %dx # '0' is 48 in ascii, result is the ascii equivalent
shl $8, %dx # move the ascii byte to %dh
pushw %dx # puch ascii code on the stack
inc %esp # point to the ascii byte! (discard %dl)
inc %ecx # count the digits
cmp $0, %eax
jnz loop
movl $4, %eax # write()
movl $1, %ebx # stdout
movl %ecx, %edx # now edx holds the number of digits
movl %esp, %ecx # load the address of string array
int $0x80 # the string array is on top of the stack
Cheers!