From: Ed Beroset
Subject: Re: Directly writing to memor
Darryl Gregorash wrote:
>
> Replying to a message of Jasen Betts to DARRYL GREGORASH:
>
> DG>> That means nothing can ever be written onto the bottom of
> DG>> the stack, ye has always struck me as rather odd..
>
> JB> no since different sized things can go onto the stack...
>
> Forget about the calls and ints.. when you decrement the stack pointer,
hen
> write to the stack, nothing can be written onto the bottom of the stack.
> Period.
Try this:
mov ax,1234h
mov sp,2
push ax
I think you'll find that the bottom of the stack (e.g. ss:0) is indeed
written to.
> JB> it also menas SP can be initialised to 0 and the first push
> JB> will write to bytes FFFF & FFFE
>
> Are you really sure of that? I'm not going to check, but more likely it
ill
> trigger a stack exception; it certainly will in 32-bit mode.
He's correct as far as real mode goes. As for protected mode, 16- or
32-bit, since the stack pointer is decremented first, one can set up the
stack pointer to two bytes or four bytes beyond the SS segment limit and
do a push of a 16- or 32-bit value without triggering any fault.
> Besides, most people are not in the habit of allocating a 64K stack.. *and*
> such segment wrap may or may not happen on anything but an 8088 or 286.. I
> don't recall if segment wrap is a feature of the 386+ 16-bit mode.. in any
> event, IMO it is shoddy programming practice to rely on something like
at.
Address space wrapping on a Pentium will cause shutdown; however
specifying an address that is just above the stack segment limit will
not. When entering protected mode, it's common practice to specify an
initial stack pointer of two bytes above in either 16- or 32-bit mode,
since a word is the smallest unit that can be pushed onto the stack.
Ed
-!-
---
---------------
* Origin: The Circuit! Board * Spokane * (1:346/100)
|