Beruflich Dokumente
Kultur Dokumente
Overview
Instruction set
Instruction details
Function
Range
R0
0-255
R1
0-255
R2
0-255
R3
0-255
RHOLD
0-255
RX
0-4
RX
0-4
RY
0-4
RZ
0-4
Timer
There is a single user timer that counts from a preloaded value down to zero in 1 second intervals.
Stacks
The DP has two stacks, a user stack and a return address stack. The return address stack holds the return address for Jump
to Subroutine (JSR) instructions and is not directly accessible. The user stack is 33 levels deep and can be used to push/pull
any user register. It is also used to perform math and logical operations by pushing the values on to the stack, then
executing the operation, the result being pushed back onto the stack. To that end DUP, DROP, SWAP, OVER and ROT stack
operators are also implemented. This is a similar to the FORTH programming language and not by coincidence:-).
The user stack pointer has wrap around capability so unmatched push/pull operations won't overwrite memory outside
the stack
This is important as the ADD/SUB/OR/AND/XOR operators always push the result of the operation onto the stack. This
means you don't have to pull the result unless you need it, but you should remember it is on the stack if you have
something else pushed on the stack previously. See also DROP instruction which discards the entry on the top-ofstack.
The user stack can hold a maximum of 33 entries.
Be aware that the PUSHXYZ and PULLXYZ instructions use 3 stack entries.
The return address stack does not wrap and has no over/under flow checking.
The return address stack can hold up to 8 return addresses.
Flags
Fcarry - Set if carry occurred during add instruction, cleared if no borrow occurred during subtract (same as underlying
PIC operations)
Fzero - Set if result was zero, cleared if result was non-zero. Fzero flag is also modified by TSTVOX, CMP, Timer and
external switch instructions.
Instruction Set
r - register name
k - literal, constant data or label
Mnemonic
Description
NOOP
No operation
MSET
MCLR
MINV
SETALL
Turn on all voxels in cube (independant of MSET, MCLR and MINV instructions)
CLRALL
Turn off all voxels in cube (independant of MSET, MCLR and MINV instructions)
INVALL
Invert all voxels in cube (independant of MSET, MCLR and MINV instructions)
SHOW
Transfer drawing buffer to display and load value in RHOLD register into hold
timer
Flags Register
VOX k,k,k
[ 0 <= k <= 4 ]
RX,RY,RZ
VOXM
TSTVOX
CHYR r
CHZR r
CHY k
Draw ASCII character value k in the Y (vertical) plane [32 <= k <= 95]
CHZ k
Draw ASCII character value k in the Z (horizontal) plane [32 <= k <= 95]
LINE k,k,k,k
LINEX
LINEY
LINEZ
PLANEX
PLANEY
PLANEZ
ROTATEX
SHXL
SHXR
SHYU
SHYD
SHZF
SHZB
DECX
Fzero RX
DECY
Fzero RY
DECZ
Fzero RZ
INCX
Fzero RX
INCY
Fzero RY
INCZ
Fzero RZ
DECR r
Fzero r
DECRSZ r
INCR r
INCRSZ r
PUSHR r
PULLR r
PUSHXYZ
PULLXYZ
Fzero
RX,RY,RZ
r
Fzero r
r
RX,RY,RZ
PULLXYZ
DROP
SWAP
DUP
OVER
ROT
TSTZ
Test value on top of stack and condition Fzero flag (a -- a ) : a==0 Fzero set,
a != 0 Fzero clear
Fzero
ADD
pulls two values from the stack, adds them together and pushes result back
onto stack
Fzero
Fcarry
SUB
pulls two values from the stack, subtracts them and pushes result back onto
stack
order is (TopOfStack-1) - (TopOfStack) -> TopOfStack
Fzero
Fcarry
AND
OR
pulls
onto
pulls
onto
RX,RY,RZ
(a b -- a a b )
two values from the stack, performs a bitwise 'AND' result is pushed back
stack
two values from the stack, performs a bitwise 'OR' result is pushed back
stack
Fzero
Fzero
XOR
pulls two values from the stack, performs a bitwise 'XOR' result is pushed back
onto stack
Fzero
NOT
pull value from top of stack, perform bitwise 'NOT' operation on byte and push
result back on to stack
Fzero
CMP r, k
Fzero
LDXYZ k,k,k
LDR r,k
LDRAND r,k
Load register with random number in the range [ 0 <= Random Number < k ]
LDTMR k
ADDTRND k
Add random number in the range [ 0 <= Random Number < k ] to contents of
Timer
SKIPZ
SKIPNZ
SKIPC
SKIPNC
SKIPTOUT
JUMP k
JSR k
RET
RANDSEED
SYNCEXT k
Wait for a falling edge on SW1 input before continuing program execution or
timer out
Fzero
TSTSW
Test SW1 input. Set Fzero flag if switch active (pressed), Clear Fzero flag if
switch not active
Fzero
Instruction details
SHOW
[ 0 <= k <= 4 ]
RX,RY,RZ
r
r
SHOW
All drawing instructions operate on the drawing buffer. This allows a new image to be built up in the drawing buffer while the
LED cube displays the contents of the display buffer. To transfer the drawing buffer into the display buffer you must use the
SHOW instruction. When the show instruction is executed it will wait for the previous hold delay to complete if it is still
active. It then sets the buffer transfer flag and waits for the display driver to copy the drawing buffer into the display buffer
and clear the transfer flag. At this time the value in RHOLD is transferred into the hold timer and the instruction exits.
RHOLD timer is period to wait x 10mS.
This command is blocking, program execution will not continue until the current hold timer has timed out and the interrupt
display driver has transferred the buffer.
MSET, MCLR, MINV instructions control the operation of VOX, PUT, LINE and PLANE instructions.
MSET turns on voxels
MCLR turns off voxels
MINV inverts the current voxel state
The operating mode remains in effect until changed by another instruction.
Stack operations
Stack Notation:
( stack before -- stack after ) e.g. SWAP
PUSHXYZ
PULLXYZ
( a b -- b a )
( -- Z Y X)
( Z Y X -- )
These two instructions push and pull the X,Y and Z registers to/from the user stack in a single command. The order the
registers are pushed onto the stack is X-Y-Z, so the Z register is at the top-of-stack after a PUSHXYZ instruction.
PUSHR Rn
PULLR Rn
( -- Rn)
( Rn -- )
Push or pull the single register to/from the top of the user stack
DROP ( a -- )
discards the top entry from the stack
SWAP ( a b -- b a )
swaps the top two values on the stack
DUP ( a -- a a )
duplicates the top entry onto the top of the stack
OVER (a b -- a b a )
inserts copy of the top stack entry behind the second entry
ROT ( a b c -- b c a)
rotates the top three entries on the stack.
LDTMR, ADDTRND and SKIPTOUT instructions control the operation of a user timer.
The timer is loaded with the number of seconds required for the timer period. It then counts down until it reaches zero and
stops. The SKIPTOUT instruction tests the current value in the timer and will skip the next instruction when it reaches zero.
ADDTRND instruction adds a random value between 0 and k-1 to the value already in the timer. This allows the timer to be
loaded with a random value between any two values, by using a LDTMR instruction followed by a ADDTRND instruction.
SYNCEXT
The sync external instruction waits for a falling edge on the S1 input or a timeout before continuing program execution.
If the timeout value is set to 0, the instruction waits indefinitely for a falling edge before continuing. If the timeout value is
set between 1 and 255, the instruction waits until either a falling edge is detected or the timer reaches 0. The timer
decrements at one second intervals and is shared with the other timer instructions. The timer is not cleared if the instruction
exits on a falling edge.
The Fzero flag is set if the instruction exits on a falling edge, and cleared if it exits on a time out.
SYNCEXT 0
SYNCEXT 12
There is no software debouncing implemented on this control input, it expects a clean logic level signal.
TSTSW
The TSTSW instruction reads the logic level on the switch input. If the logic level is low (switch pressed) the Fzero flag is
set, if the logic level is high (switch not pressed) the Fzero flag is cleared. This instruction is not blocking, the input is
tested, the Fzero flag conditioned and code execution continues.
SHXL, SHXR, SHYU, SHYD, SHZF, SHZB instructions shift the entire drawing buffer one voxel in the direction specified.
The voxels at the incoming edge of the shift are cleared (set to off)
Example.
Shift down:
Before
After
MSET
LDXYZ 0,4,2
LINE 0, -1, 1, 2
RX
RY
RZ
RX
RY
RZ
MSET
LDXYZ 2,2,2
LINE -1, 0, 1, 4
MSET
LDXYZ 0,0,0
LINE 0, 0, 1, 5
RX RY RZ
RX
RY
RZ
0
4
2
2
4
0
<- rollover
LINEX
located in the Y-Z planes by the current values of RY and RZ
Example of LINEX.
LINEY
located in the X-Z planes by the current values of RX and RZ
LINEZ
Given the way the PLANEY and PLANEZ commands work you would expect CHY and CHZ commands to work the opposite
way round to the way they do and I wouldn't disagree but if I change it now it breaks any code people may have already
written.