From: Ed Beroset
Subject: Re: Directly writing to memor
At 20:28 1/28/98, you wrote:
>
> *** Darryl Gregorash wrote in a message to Scott McNay:
>
> DG>> mov ss:[sp], eax
> DG>> sub sp,4
>
>
> SM> Shouldn't that be the other way around?
>
>DG> I don't think so; it mimics a PUSH.
>
>Last I heard, SP pointed at the top of the stack, so that SS:[SP] would
efer
>to the last item. Meaning, to add another value to the stack, you must
irst
>decrement sp, then move the new value, as in:
>
> sub sp,4
> mov ss:[sp],eax
You're correct. The stack pointer is decremented before the register is
copied to memory.
> SM> (assuming, of course, that mov ax,ss:[sp] worked ;)
>
>DG> Why wouldn't it?
>
>Did you try it? Microsoft's DEBUG says "error", and OpenDOS's DEBUG says
>"Incorrect name of index register".
That's because it's not a legal addressing mode. If you examine a chart of
the ModR/M byte addressing forms, you'll see that there is no way to
specify [sp] as a destination address.
Ed
-!-
---
---------------
* Origin: The Circuit! Board * Spokane * (1:346/100)
|