Data Organization and Addressing Capabilities
MOTOROLA MC68030 USER’S MANUAL 2-39
In this case, after either a push or pull operation, register An points to the next available
space on the stack. This is illustrated as:
2.8.3 Queues
The user can implement queues with the address register indirect with postincrement or
predecrement addressing modes. Using a pair of address registers (who of A0–A6), the user
can implement a queue which is filled either from high to low memory or from low to high
memory. Two registers are used because queues are pushed from one end and pulled from
the other. One register, An, contains the "put'' pointer; the other, Am, the "get'' pointer.
To implement growth of the queue from low to high memory, use:
(An)+ to put data into the queue,
(Am)+ to get data from the queue.
After a "put'' operation, the "put'' address register points to the next available space in the
queue, and the unchanged "get'' address register points to the next item to be removed from
the queue. After a "get'' operation, the "get'' address register points to the next item to be
removed from the queue, and the unchanged "put'' address register points to the next
available space in the queue. This is illustrated as:
To implement the queue as a circular buffer, the relevant address register should be
checked and adjusted, if necessary, before performing the "put'' or "get'' operation. The
address register is adjusted by subtracting the buffer length (in bytes) from the register.
LOW MEMORY
TOP OF STACK
HIGH MEMORY
An
BOTTOM OF STACK
(FREE)
GET (Am) +
LOW MEMORY
(FREE)
HIGH MEMORY
LAST GET (FREE)
LAST PUT
NEXT GET
PUT (An) +