CPU_DataStructures.i

Summary
CPU_DataStructures.i
FIFO
FIFO_allocAllocate static FIFO (queue) buffer
FIFO_enqWrite (enqueue) byte to FIFO buffer
FIFO_deqRead (dequeue) byte from FIFO buffer
FILO
FILO_allocAllocate static FILO (stack) buffer
FILO_pushWrite byte to FILO buffer
FILO_popRead byte from FILO buffer

FIFO

FIFO_alloc

Allocate static FIFO (queue) buffer

Buffer is allocated in the LORAM segment.  Implemented as a circular buffer without overrun protection.

Parameters

:in:    name    Name                  identifier  Any string (without quotes)
:in:    size    Capacity in bytes     constant    Power of two integer up to 256 bytes

Example

FIFO_alloc    TestFIFO, 32

FIFO_enq      TestFIFO, $f
FIFO_enq      TestFIFO, $0
lda           #$0
FIFO_enq      TestFIFO, a
lda           #$d
FIFO_enq      TestFIFO, a

FIFO_deq      TestFIFO           ;y = #$0f, z = 0
FIFO_deq      TestFIFO, a        ;a = #$00, z = 0
FIFO_deq      TestFIFO           ;y = #$00, z = 0
FIFO_deq      TestFIFO           ;y = #$0d, z = 0
FIFO_deq      TestFIFO           ;z = 1 -> Buffer empty

FIFO_enq

Write (enqueue) byte to FIFO buffer

Destroys a and x.

Parameters

:in:    name    Buffer name           identifier  Any string (without quotes)
:in:    data    Data (int8)           a           Enqueue value in accumulator
                                      constant    Enqueue assemble-time constant

FIFO_deq

Read (dequeue) byte from FIFO buffer

Value is returned in ‘outreg’ (default y), z = 0.  If queue is empty z = 1.

Destroys a and x or y.

Parameters

:in:    name    Buffer name           identifier  Any string (without quotes)
:out?:  outreg  Return register       identifier  y/x/a

FILO

FILO_alloc

Allocate static FILO (stack) buffer

Buffer is allocated in the LORAM segment.  No overflow protection.

Parameters

:in:    name    Name                  identifier  Any string (without quotes)
:in:    size    Capacity in bytes     constant    Power of two integer up to 256 bytes

Example

FILO_alloc  TestFILO, 32

FILO_push   TestFILO, $b
FILO_push   TestFILO, $e
lda         #$e
FILO_push   TestFILO, a
lda         #$f
FILO_push   TestFILO, a

FILO_pop    TestFILO            ;y = #$0f, z = 0
FILO_pop    TestFILO, a         ;a = #$0e, z = 0
FILO_pop    TestFILO            ;y = #$0e, z = 0
FILO_pop    TestFILO            ;y = #$0b, z = 0
FILO_pop    TestFILO            ;z = 1 -> Buffer empty

FILO_push

Write byte to FILO buffer

Destroys x.

Parameters

:in:    name    Buffer name           identifier  Any string (without quotes)
:in:    data    Data (int8)           a           Push value in accumulator
                                      constant    Push assemble-time constant

FILO_pop

Read byte from FILO buffer

Value is returned in ‘outreg’ (default y), z = 0.  If stack is empty z = 1.

Destroys a and x or y.

Parameters

:in:    name    Buffer name           identifier  Any string (without quotes)
:out?:  outreg  Return register       identifier  y/x/a