Hardware Reference
In-Depth Information
The stack segment is made up of 2-byte words and so the stack pointer, SP ,
should always contain an even number. The stack is filled up from high addresses
to low addresses. Thus, the PUSH instruction decreases the stack pointer by 2 and
then stores the operand in the memory address computed from SS and SP . The
POP command retrieves the value, and increments SP by 2. Addresses in the stack
segment which are lower than those indicated by SP are considered free. Stack
cleanup is thus achieved by merely increasing SP . In practice, DS and SS are
always the same, so a 16-bit pointer can be used to refer to a variable in the shared
data/stack segment. If DS and SS were different, a 17th bit would be needed on
each pointer to distinguish pointers into the data segment from pointers into the
stack segment. In retrospect, having a separate stack segment at all was probably a
mistake.
If addresses in the four segment registers are chosen to be far apart, then the
four segments will be disjointed, but if the available memory is restricted, it is not
necessary to make them disjoint. After compilation, the size of the program code is
known. It is then efficient to start the data and stack segments at the first multiple
of 16 after the last instruction. This assumes that the code and data segment will
never use the same physical addresses.
C.3.2 Addressing
Almost every instruction needs data, either from memory or from the registers.
To name this data, the 8088 has a reasonably versatile collection of addressing
modes. Many instructions contain two operands, usually called destination and
source . Think, for instance, about the copy instruction, or the add instruction:
MOV AX,BX
or
ADD CX,20
In these instructions, the first operand is destination and the second is the source.
(The choice of which goes first is arbitrary; the reverse choice could also have been
made.) It goes without saying that, in such a case, the destination must be a left
value that is, it must be a place where something can be stored. This means that
constants can be sources, but not destinations.
In its original design, the 8088 required that at least one operand in a two-
operand instruction be a register. This was done so that the difference between
word instructions, and byte instructions could be seen by checking whether the
addressed register was a word register or a byte register . In the first release of
the processor, this idea was so strictly enforced that it was impossible to push a
constant, because neither the source nor the destination was a register in that in-
struction.
Later versions were not as strict, but the idea influenced the design
 
 
Search WWH ::




Custom Search