Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

ASM Question

Name: Anonymous 2011-03-09 1:33

A section from the ASM guide I'm reading:
"MOV  AX,51h
MOV  BX,4Fh
XCHG AX,BX
PUSH AX
MOV  AX,34h
POP  BX
PUSH BX
POP  AX
First AX is equal to 51h and BX to 4Fh, than the 2 get exchanged.  Now we got
AX = 4Fh and BX = 51h.  AX gets pushed on the stack, then set to 34h:
AX = 34h and BX = 51h.  BX gets poped, than pushed:
AX = 34h and BX = 4Fh.  Finally AX gets poped.  So the final result is:
AX = 4Fh and BX = 4Fh"


Can someone please explain why AX= 4Fh and not 34h?? That's the last value that was copied to it.

Name: Anonymous 2011-03-09 4:18

POP stuff is just:
mov stuff,[(e)sp]
add (e)sp,{size of popped object}

Or just take whatever is at the top of the stack and place it in the argument passed to pop then add the stack pointer by the size of popped object (usually 2-4 bytes depending on CPU mode, see Intel CPU documentation for details).

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List