Re: asm and nasm newbie




Zhang Huan wrote:
| hi all:
Hi,
| want to get parameter from stack, i use "mov di, [sp+4]". while
| compiling error occurs "invalid effective address". what's wrong

[sp+4] is not available at all.

[esp+4] is a valid addressing form, but only as a 32-bit part.

so if you use 16 bit code you either can try:

mov di,[esp+4]

which most tools wont understand and cry, as this needs
a 67h prefix and a SIB-addressing mode in 16-bit code.

or make it a DB-code then:

;:use16 ;I assume to be 16-bit
67 8b 7c 24 04 mov di,[esp+4]

if used in true realmode (not VM86) then you can quietly
ignore the high-word of ESP, as it is zero then anyway.

for VM86 you better use 'the standard':

push bp
mov bp,sp
mov di,[bp+6] ;+2 as bp were pushed yet
....
pop bp

__
wolfgang



.