Hello,
I'm trying to write programs to mimic C "for loops". I seem to come up
with a new idea for an algorithm daily, so I'm sure there are many
ways to do this.
#forloop.s
#modular <[EMAIL PROTECTED]>
.section .data
output:
.asciz "%d\n"
.section .text
.globl _start
_start:
nop
movl $1, -4(%esp)
compare:
cmpl $10, -4(%esp)
jle forloop
jmp end
forloop:
pushl -4(%esp)
pushl $output
call printf
addl $8, %esp
incl -4(%esp)
jmp compare
end:
pushl $0
call exit
I'm using -4(%esp) to store the counter in, but really want to use
registers in the program. If I use %ecx for example, it just keeps get
reset. I just popl off the stack, but I keep getting infinite loops.
Any hints to how this can be done?
Regards,
modular
_______________________________________________
Pgubook-readers mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/pgubook-readers