Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mov reg16, [sp] doesn't work!!

Status
Not open for further replies.

smgarth

Programmer
Mar 12, 2004
20
US
I can't figure this out. All I need to do is mov the contents of sp into a register, but nasm complains 'invalid effective address'. I've tried it with every single register combination, but it won't let me do it. Please help!
 
If you want to move the contents of the stack pointer into another register, you need
mov ax, sp
i.e. you shouldn't in this case be using the square brackets, which mean "calculate an effective address". I use tasm, not nasm, so there may be some differences; sorry if I'm misinforming you.
If you want to move the thing in a memory location pointed to by sp into another register, then I don't think
mov ax, [sp] is valid.
I think you should consider just doing
pop ax
push ax
which I think should achieve the same result.
Hope that helps...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top