Queues - Motorola CPU32 Reference Manual

Hide thumbs Also See for CPU32:
Table of Contents

Advertisement

3.7.3 Queues

Queues can be implemented using the address register indirect with postincrement or
predecrement addressing modes. Queues are pushed from one end and pulled from
the other, and use two registers. A queue filled either from high to low memory or from
low to high memory can be implemented with a pair (two of A0 to A6) of address reg-
isters. (An) is the "put" pointer and (Am) is 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" register points to the next available queue space, and
the unchanged "get" register points to the next item to be removed from the queue.
After a "get" operation, the "get" register points to the next item to be removed from the
queue, and the unchanged "put" register points to the next available queue space,
which is illustrated as follows:
To implement a queue as a circular buffer, the relevant address register should be
checked and (if necessary) adjusted before performing a "put" or "get" operation. The
address register is adjusted by subtracting the buffer length (in bytes) from the register
contents.
To implement growth of the queue from high to low memory, use –(An) to put data into
the queue, –(Am) to get data from the queue.
After a "put" operation, the "put" register points to the last item placed in the queue,
and the unchanged "get" address register points to the last item removed from the
queue. After a "get" operation, the "get" register points to the last item removed from
the queue, and the unchanged "put" register points to the last item placed in the queue,
which is illustrated as follows:
CPU32
DATA ORGANIZATION AND ADDRESSING CAPABILITIES
REFERENCE MANUAL
LOW MEMORY
BOTTOM OF STACK
TOP OF STACK
An
(FREE)
HIGH MEMORY
LOW MEMORY
LAST GET (FREE)
GET (Am) +
NEXT GET
LAST PUT
PUT (An) +
(FREE)
HIGH MEMORY
MOTOROLA
3-17

Advertisement

Table of Contents
loading

Table of Contents