TIP: Click on subject to list as thread! ANSI
echo: 80xxx
to: SCOTT MCNAY
from: DARRYL GREGORASH
date: 1998-01-29 18:03:00
subject: Directly writing to memor

Replying to a message of Scott McNay to Darryl Gregorash:
 SM> Last I heard, SP pointed at the top of the stack, so that
 SM> SS:[SP] would refer to the last item.  Meaning, to add
 SM> another value to the stack, you must first decrement sp,
 SM> then move the new value, as in:
Hmm, I may have been reading the pseudocode for the POP instr when I wrote 
that up :)
That means nothing can ever be written onto the bottom of the stack, yes? 
That has always struck me as rather odd.. 
 SM>> (assuming, of course, that mov ax,ss:[sp] worked ;)
 DG>> Why wouldn't it?
 SM> Did you try it?  Microsoft's DEBUG says "error", and
 SM> OpenDOS's DEBUG says "Incorrect name of index register".
What debug allows and what the CPU allows are not always the same thing. ESP 
is a legal indirect memory operand in 32-bit mode, but I forgot that SP isn't 
legal in 16-bit mode. In fact, in 32-bit mode, any general purpose 32-bit 
register can be used as a mem operand, except that:
(From the Intel software developer's manual, vol 1)
The uses of general-purpose registers as base or index components are 
restricted in the following manner:
- The ESP register cannot be used as an index register.
- When the ESP or EBP register is used as the base, the SS segment is the 
default segment.
In all other cases, the DS segment is the default segment.
--- FleetStreet 1.21 NR
---------------
* Origin: BIG BANG Burger Bar: Regina SK Canada (1:140/86)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.