NASM - The Netwide Assembler

NASM Forum => Using NASM => Topic started by: Nathan Handler on February 16, 2008, 04:01:06 AM

Title: Program Issue (loop)
Post by: Nathan Handler on February 16, 2008, 04:01:06 AM
I have a program that is meant to display the top 5 items in the stack. However, it only displays the top item. I'm new to nasm and running it on ubuntu. Any help would be appreciated.

http://pastebin.com/m1f2aa8a2 (http://pastebin.com/m1f2aa8a2)
Title: Re: Program Issue (loop)
Post by: nobody on February 16, 2008, 04:19:30 AM
Since the int 80h returns the number of bytes written in eax, you need to reload eax with 4 (__NT_write) *inside* your loop.

Best,
Frank
Title: Re: Program Issue (loop)
Post by: nobody on February 16, 2008, 04:21:06 AM
__NR_write...

That is...

Best,
Frank
Title: Re: Program Issue (loop)
Post by: Nathan Handler on February 16, 2008, 01:21:21 PM
Ok, moving the "mov eax,4" inside the loop made the code (http://pastebin.com/mf10e97c) work. I'm just wondering, why does it need to be inside the loop? Originally, I set eax to 4 right above the loop. Inside the loop, the value of eax was left untouched. Shouldn't it remain set to 4 throughout the entire loop?