XXIIVV

The Uxntal Manual

This documentation includes hand gestures, and glyphs, which might serve a dual purpose; both enabling the usage of the Uxntal language outside of the computer, as well as to help students to familiarize themselves with hexadecimal finger-counting and bitwise operations.

000102030405060708090a0b0c0d0e0f
00BRKINCPOPNIPSWPROTDUPOVREQUNEQGTHLTHJMPJCNJSRSTH
10LDZSTZLDRSTRLDASTADEIDEOADDSUBMULDIVANDORAEORSFT
20JCIINC2POP2NIP2SWP2ROT2DUP2OVR2EQU2NEQ2GTH2LTH2JMP2JCN2JSR2STH2
30LDZ2STZ2LDR2STR2LDA2STA2DEI2DEO2ADD2SUB2MUL2DIV2AND2ORA2EOR2SFT2
40JMIINCrPOPrNIPrSWPrROTrDUPrOVRrEQUrNEQrGTHrLTHrJMPrJCNrJSRrSTHr
50LDZrSTZrLDRrSTRrLDArSTArDEIrDEOrADDrSUBrMULrDIVrANDrORArEORrSFTr
60JSIINC2rPOP2rNIP2rSWP2rROT2rDUP2rOVR2rEQU2rNEQ2rGTH2rLTH2rJMP2rJCN2rJSR2rSTH2r
70LDZ2rSTZ2rLDR2rSTR2rLDA2rSTA2rDEI2rDEO2rADD2rSUB2rMUL2rDIV2rAND2rORA2rEOR2rSFT2r
80LITINCkPOPkNIPkSWPkROTkDUPkOVRkEQUkNEQkGTHkLTHkJMPkJCNkJSRkSTHk
90LDZkSTZkLDRkSTRkLDAkSTAkDEIkDEOkADDkSUBkMULkDIVkANDkORAkEORkSFTk
a0LIT2INC2kPOP2kNIP2kSWP2kROT2kDUP2kOVR2kEQU2kNEQ2kGTH2kLTH2kJMP2kJCN2kJSR2kSTH2k
b0LDZ2kSTZ2kLDR2kSTR2kLDA2kSTA2kDEI2kDEO2kADD2kSUB2kMUL2kDIV2kAND2kORA2kEOR2kSFT2k
c0LITrINCkrPOPkrNIPkrSWPkrROTkrDUPkrOVRkrEQUkrNEQkrGTHkrLTHkrJMPkrJCNkrJSRkrSTHkr
d0LDZkrSTZkrLDRkrSTRkrLDAkrSTAkrDEIkrDEOkrADDkrSUBkrMULkrDIVkrANDkrORAkrEORkrSFTkr
e0LIT2rINC2krPOP2krNIP2krSWP2krROT2krDUP2krOVR2krEQU2krNEQ2krGTH2krLTH2krJMP2krJCN2krJSR2krSTH2kr
f0LDZ2krSTZ2krLDR2krSTR2krLDA2krSTA2krDEI2krDEO2krADD2krSUB2krMUL2krDIV2krAND2krORA2krEOR2krSFT2kr

Break

BRK -- Ends the evalutation of the current vector. This opcode has no modes.

Jump Conditional Instant

JCI cond8 -- Pops a byte from the working stack and if it is not zero, moves the PC to a relative address at a distance equal to the next short in memory, otherwise moves PC+2. This opcode has no modes.

Jump Instant

JMI -- Moves the PC to a relative address at a distance equal to the next short in memory. This opcode has no modes.

Jump Stash Return Instant

JSI -- Pushes PC+2 to the return-stack and moves the PC to a relative address at a distance equal to the next short in memory. This opcode has no modes.

Literal

LIT -- a Pushes the next bytes in memory, and moves the PC+2. The LIT opcode always has the keep mode active. Notice how the 0x00 opcode, with the keep bit toggled, is the location of the literal opcodes. To learn more, see literals.

LIT 12          ( 12 )
LIT2 abcd       ( ab cd )

Increment

INC a -- b Increments the value at the top of the stack, by 1.

#01 INC         ( 02 )
#0001 INC2      ( 00 02 )
#0001 INC2k     ( 00 01 00 02 )

Pop

POP a -- Removes the value at the top of the stack.

#1234 POP    ( 12 )
#1234 POP2   ( )
#1234 POP2k  ( 12 34 )

Nip

NIP a b -- b Removes the second value from the stack. This is practical to convert a small short into a byte.

#1234 NIP          ( 34 )
#1234 #5678 NIP2   ( 56 78 )
#1234 #5678 NIP2k  ( 12 34 56 78 56 78 )

Swap

SWP a b -- b a Exchanges the first and second values at the top of the stack.

#1234 SWP          ( 34 12 )
#1234 SWPk         ( 12 34 34 12 )
#1234 #5678 SWP2   ( 56 78 12 34 )
#1234 #5678 SWP2k  ( 12 34 56 78 56 78 12 34 )

Rotate

ROT a b c -- b c a Rotates three values at the top of the stack, to the left, wrapping around.

#1234 #56 ROT            ( 34 56 12 )
#1234 #56 ROTk           ( 12 34 56 34 56 12 )
#1234 #5678 #9abc ROT2   ( 56 78 9a bc 12 34 )
#1234 #5678 #9abc ROT2k  ( 12 34 56 78 9a bc 56 78 9a bc 12 34 )

Duplicate

DUP a -- a a Duplicates the value at the top of the stack.

#1234 DUP   ( 12 34 34 )
#12 DUPk    ( 12 12 12 )
#1234 DUP2  ( 12 34 12 34 )

Over

OVR a b -- a b a Duplicates the second value at the top of the stack.

#1234 OVR          ( 12 34 12 )
#1234 OVRk         ( 12 34 12 34 12 )
#1234 #5678 OVR2   ( 12 34 56 78 12 34 )
#1234 #5678 OVR2k  ( 12 34 56 78 12 34 56 78 12 34 )

Equal

EQU a b -- bool8 Pushes 01 to the stack if the two values at the top of the stack are equal, 00 otherwise.

#1212 EQU          ( 01 )
#1234 EQUk         ( 12 34 00 )
#abcd #ef01 EQU2   ( 00 )
#abcd #abcd EQU2k  ( ab cd ab cd 01 )

Not Equal

NEQ a b -- bool8 Pushes 01 to the stack if the two values at the top of the stack are not equal, 00 otherwise.

#1212 NEQ          ( 00 )
#1234 NEQk         ( 12 34 01 )
#abcd #ef01 NEQ2   ( 01 )
#abcd #abcd NEQ2k  ( ab cd ab cd 00 )

Greater Than

GTH a b -- bool8 Pushes 01 to the stack if the second value at the top of the stack is greater than the value at the top of the stack, 00 otherwise.

#1234 GTH          ( 00 )
#3412 GTHk         ( 34 12 01 )
#3456 #1234 GTH2   ( 01 )
#1234 #3456 GTH2k  ( 12 34 34 56 00 )

Lesser Than

LTH a b -- bool8 Pushes 01 to the stack if the second value at the top of the stack is lesser than the value at the top of the stack, 00 otherwise.

#0101 LTH          ( 00 )
#0100 LTHk         ( 01 00 00 )
#0001 #0000 LTH2   ( 00 )
#0001 #0000 LTH2k  ( 00 01 00 00 00 )

Jump

JMP addr -- Moves the PC by a relative distance equal to the signed byte on the top of the stack, or to an absolute address in short mode.

,&skip-rel JMP BRK &skip-rel #01  ( 01 )

Jump Conditional

JCN cond8 addr -- If the byte preceeding the address is not 00, moves the PC by a signed value equal to the byte on the top of the stack, or to an absolute address in short mode.

#abcd #01 ,&pass JCN SWP &pass POP  ( ab )
#abcd #00 ,&fail JCN SWP &fail POP  ( cd )

Jump Stash Return

JSR addr -- Pushes the PC to the return-stack and moves the PC by a signed value equal to the byte on the top of the stack, or to an absolute address in short mode.

,&get JSR #01 BRK &get #02 JMP2r  ( 02 01 )

Stash

STH a -- Moves the value at the top of the stack, to the return stack.

#01 STH LITr 02 ADDr STHr  ( 03 )

Load Zero-Page

LDZ addr8 -- value Pushes the value at an address within the first 256 bytes of memory, to the top of the stack.

|00 @cell $2 |0100 .cell LDZ ( 00 )

Store Zero-Page

STZ val addr8 -- Writes a value to an address within the first 256 bytes of memory.

|00 @cell $2 |0100 #abcd .cell STZ2  { ab cd }

Load Relative

LDR addr8 -- value Pushes a value at a relative address in relation to the PC, within a range between -128 and +127 bytes, to the top of the stack.

,cell LDR2 BRK @cell abcd  ( ab cd )

Store Relative

STR val addr8 -- Writes a value to a relative address in relation to the PC, within a range between -128 and +127 bytes.

#1234 ,cell STR2 BRK @cell $2  ( )

Load Absolute

LDA addr16 -- value Pushes the value at a absolute address, to the top of the stack.

;cell LDA BRK @cell abcd ( ab )

Store Absolute

STA val addr16 -- Writes a value to a absolute address.

#abcd ;cell STA BRK @cell $1 ( ab )

Device Input

DEI device8 -- value Pushes a value from the device page, to the top of the stack. The target device might capture the reading to trigger an I/O event.

Device Output

DEO val device8 -- Writes a value to the device page. The target device might capture the writing to trigger an I/O event.


Add

ADD a b -- c Pushes the sum of the two values at the top of the stack.

#1a #2e ADD       ( 48 )
#02 #5d ADDk      ( 01 5d 5f )
#0001 #0002 ADD2  ( 00 03 )

Subtract

SUB a b -- c Pushes the difference of the first value minus the second, to the top of the stack.

Multiply

MUL a b -- c Pushes the product of the first and second values at the top of the stack.

Divide

DIV a b -- c Pushes the quotient of the first value over the second, to the top of the stack.


And

AND a b -- c Pushes the result of the bitwise operation AND, to the top of the stack.

Or

ORA a b -- c Pushes the result of the bitwise operation OR, to the top of the stack.

Exclusive Or

EOR a b -- c Pushes the result of the bitwise operation XOR, to the top of the stack.

Shift

SFT a shift8 -- c Shifts the bits of the second value of the stack to the left or right, depending on the control value at the top of the stack. The high nibble of the control value indicates how many bits to shift left, and the low nibble how many bits to shift right. The rightward shift is done first.

#34 #10 SFT        ( 68 )
#34 #01 SFT        ( 1a )
#34 #33 SFTk       ( 34 33 30 )
#1248 #34 SFTk2    ( 12 48 34 09 20 )

Incoming: uxntal opcodes