Author Topic: Program Issue (loop)  (Read 8853 times)

Nathan Handler

  • Guest
Program Issue (loop)
« 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

nobody

  • Guest
Re: Program Issue (loop)
« Reply #1 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

nobody

  • Guest
Re: Program Issue (loop)
« Reply #2 on: February 16, 2008, 04:21:06 AM »
__NR_write...

That is...

Best,
Frank

Nathan Handler

  • Guest
Re: Program Issue (loop)
« Reply #3 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?