Page 1 of 1
mov reg16, [sp] doesn't work!!
Posted: Fri Mar 19, 2004 12:00 am
by Neptune
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!
RE:mov reg16, [sp] doesn't work!!
Posted: Sat Mar 20, 2004 12:00 am
by Khumba
If you want to move the address SP points to into a register, use "mov reg16, sp". You can't use [sp], because x86 assembly removed that in order to have a plain [offset] addressing mode. So you'll have to load SP into another register (BX, BP, SI, or DI) and use that instead.
RE:mov reg16, [sp] doesn't work!!
Posted: Sat Mar 20, 2004 12:00 am
by Khumba
Actually, there's no [bp] mode either, only [bp+offset], but good compilers (like nasm) translate this to [bp+0].
RE:mov reg16, [sp] doesn't work!!
Posted: Sat Mar 20, 2004 12:00 am
by Neptune
Thank you!