Motorola M68000 Guida Utente Pagina 103

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 256
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 102
CHAPTER 7
THE STACK
In this chapter we will examine the hardware stack implementation
on the 68000. A stack is a type of data structure. Computer scientists refer
to data structures like stacks as abstract data types. This is because we
manipulate the data items contained on the stack by indirect means. In
other words, we do not have to know the exact details of the particular
abstract data structure in order to use it. The 68000 provides a number of
addressing modes and instructions that can be used to manipulate data
on a stack. Additionally, a number of other instructions use the stack to
support their main functions. The JSR instruction that we have already
used is a good example.
A stack is just about what its name implies: a stack of data elements. As
with a stack of dishes or books, items are normally added to or removed
from the top of the stack. While it is possible to add or remove an element
from the middle of a stack, it is not a proper use. The data elements that
form a 68000 stack may be bytes, words, or longwords. A stack may be
placed anywhere in memory. It can be of any size. Normally, one of the
eight address registers, A0 through A7, is used to reference the contents
of a stack. However, register A7 is the register that is used by many
instructions, such as JSR, to implicitly reference a stack. This register
also has the symbolic representation SP (stack pointer). The diagram on the
following page shows what an empty stack looks like. Each position in the
stack is capable of holding a different value. The initial contents of the stack
are of no significance. Whatever values are in the respective memory
addresses are indicated by the question marks in the diagram. The actual
length of the stack is up to the programmer as long as the total length fits
within an area the programmer has reserved.
Stack Instructions
While it might seem a bit confusing, the 68000 hardware stack is upside
down. That is, when we add something to the stack, the elements are
added to progressively lower memory addresses. For each data element
89
Vedere la pagina 102
1 2 ... 98 99 100 101 102 103 104 105 106 107 108 ... 255 256

Commenti su questo manuale

Nessun commento