Chip32-vm

WordsMnemonicZCDescription
0000NOP

..

no operation

020x nnnnLD.b Rx,(nnnn)

Z.

(n) -> Rx

030x nnnnLD.b (nnnn),Rx

..

Rx -> (n)

040x nnnnLD.w Rx,(nnnn)

Z.

(n) -> Rx

050x nnnnLD.w (nnnn),Rx

..

Rx -> (n)

060x nnnnLD.l Rx,(nnnn)

Z.

(n) -> Rx

070x nnnnLD.l (nnnn),Rx

..

Rx -> (n)

080x nnnnLD Rx,#imm16

Z.

n -> Rx

090x nnnnAND Rx,#imm16

Z.

Rx & n -> Rx

0A0x nnnnOR Rx,#imm16

Z.

Rx | n -> Rx

0B0x nnnnXOR Rx,#imm16

Z.

Rx ^ n -> Rx

0C0x nnnnADD Rx,#imm16

ZC

Rx + n -> Rx

0D0x nnnnSUB Rx,#imm16

ZC

Rx - n -> Rx

0E0x nnnnCMP Rx,#imm16

ZC

RX - n -> (not written back)

0F0x nnnnBIT Rx,#imm16

Z.

Rx & n -> (not written back)

1000 nnnn nnnnRSET #n

..

Sets the random fill parameters

11yx nnnn 000zCRC Rx,Ry,Rz,#n

..

CRC's data at Rx for length Ry using Rz for the CRC, and polynomial N

180x nnnn nnnnLD Rx,#imm32

Z.

n -> Rx

190x nnnn nnnnAND Rx,#imm32

Z.

Rx & n -> Rx

1A0x nnnn nnnnOR Rx,#imm32

Z.

Rx | n -> Rx

1B0x nnnn nnnnXOR Rx,#imm32

Z.

Rx ^ n -> Rx

1C0x nnnn nnnnADD Rx,#imm32

ZC

Rx + n -> Rx

1D0x nnnn nnnnSUB Rx,#imm32

ZC

Rx - n -> Rx

1E0x nnnn nnnnCMP Rx,#imm32

ZC

RX - n -> (not written back)

1F0x nnnn nnnnBIT Rx,#imm32

Z.

Rx & n -> (not written back)

20yxASL Rx,Ry

ZC

Rx << Ry -> Rx

21yxLSR Rx,Ry

ZC

Rx >> Ry -> Rx

22yxROL Rx,Ry

ZC

Rx >>> Ry -> Rx

23yxROR Rx,Ry

ZC

RX <<< Ry -> Rx

24nxASL Rx,#n+1

ZC

Rx << n+1

25nxLSR Rx,#n+1

ZC

Rx >> n+1

26nxROL Rx,#n+1

ZC

Rx <<< n+1

27nxROR Rx,#n+1

ZC

Rx >>> n+1

28yxLD Rx,Ry

Z.

Ry -> Rx

29yxAND Rx,Ry

Z.

Rx & Ry -> Rx

2AyxOR Rx,Ry

Z.

Rx | Ry -> Rx

2ByxXOR Rx,Ry

Z.

Rx ^ Ry -> Rx

2CyxADD Rx,Ry

ZC

Rx + Ry -> Rx

2DyxSUB Rx,Ry

ZC

Rx - Ry -> Rx

2EyxCMP Rx,Ry

ZC

Ry - Rx -> (not written back)

2FyxBIT Rx,Ry

Z.

Rx & Ry -> (not written back)

32yxLD.b Rx,(Ry)

Z.

(Ry) -> Rx

33yxLD.b (Ry),Rx

..

Rx -> (Ry)

34yxLD.w Rx,(Ry)

Z.

(Ry) -> Rx

35yxLD.w (Ry),Rx

..

Rx -> (Ry)

36yxLD.l Rx,(Ry)

Z.

(Ry) -> Rx

37yxLD.l (Ry),Rx

..

Rx -> (Ry)

38yxMUL Rx,Ry

..

Rx * Ry -> Rx

39yxTEST Rx,Ry

Z.

Tests strings at Rx, Ry returns 0 for equality (and sets Z), 1 if Ry shorter than Rx, 2 for different.

3AyxPMPW Rx,Ry

..

Rx -> PMP(Ry) Writes to PMP register

3ByxPMPR Rx,Ry

..

PMP(Ry) -> Rx  Reads from PMP register

3CyxPMPBW Rx,Ry

..

Rx -> PMP(Ry) (bytes, see examples below)

3DyxXFILL Rx,Ry

..

Fills Rx with Ry words. The upper byte of Ry is the fill byte

3EyxDIV Rx,Ry

ZC

Rx / Ry -> Rx; Rx % Ry -> Ry. If dividing by 0 is attempted, will generate an error. Z set

3FyxRFILL Rx,Ry

..

Randomly fills PMP space.

400xPRINTF Rx

..

Prints string at Rx to buffer

410xHEX.b Rx

..

Prints byte of Rx to buffer in hex

411xHEX.w Rx

..

Prints word of Rx to buffer in hex

412xHEX.l Rx

..

Prints long of Rx to buffer in hex

413xDEC.b Rx

..

Prints byte of Rx to buffer in dec

414xDEC.w Rx

..

Prints word of Rx to buffer in dec

415xDEC.l Rx

..

Prints long of Rx to buffer in dec

4200RET

..

fs--, (top of stack) -> PC

4201RET NZ

..

if Z = 0, RET

4202RET Z

..

if Z = 1, RET

4203RET NC

..

if C = 0, RET

4204RET C

..

if C = 1, RET

430xPUSH Rx

..

Rx -> (top of stack), rs++

440xPOP Rx

..

rs--, (top of stack) -> Rx

45yxERR Rx, Ry

..

Loads error register into Rx and the error PC into Ry

4600EXIT 0

..

Exits code successfully

4601EXIT 1

..

Exits code with an error

4700CLC

.0

0 -> carry

4701SEC

.1

1 -> carry

48yxUIVISIBLE Rx,Ry

Z.

Rx = UI element ID, Ry = status.
1 = visible, 0 = invisible, ff = check status, returns visible or not in Z flag — not currently implemented

49yxGETTIME Rx,Ry

..

Writes a 32-bit response into Ry based on the value given in Rx:
0: Ry = UNIX timestamp (unsigned)
1: Ry = Date in BCD format
2: Ry = Time in BCD format

50yxADJFS Rx,Ry

..

Adjusts file size of file #Rx to value Ry

51yxADJFO Rx,Ry

..

Adjusts file offset of file #Rx to value Ry

52yxADJLP Rx,Ry

..

Adjusts file pmp address of file #Rx to value Ry

530xLOADF Rx

Z.

Load file Rx from json file. Rx returns length of file that was loaded

54yxGETEXT Rx, Ry

..

Returns the file extension of file Rx, and stores it into memory at Ry

55yxGETNAME Rx, Ry

..

Returns the file name of file Rx, and stores it into memory at Ry

56yxOPEN Rx,Ry

Z.

Open file Rx. Length is returned in Ry. 0 length means file does not exist or is empty.

5700CLOSE

..

Closes the open file

580xSEEK Rx

Z.

Seeks to position Rx in file

59yxREAD Rx,Ry

Z.

Reads Ry bytes from the file into memory at Rx

5AyxCOPY Rx,Ry

Z.

Copies data from the open file to PMP. Rx = where in PMP space, Ry = size.

5B0xCORE Rx

..

Select core Rx (ID)

5CyxHOST Rx,Ry

..

Performs a host command. (reset, run, etc)

5D0xQUERYSLOT Rx

Z.

Tests whether there is a valid file in a json slot. Z is set if the file is valid/exists, clear if it doesn't.

6nnnJP n

..

n*2 -> PC

7nnnJP NZ,n

..

if Z = 0, JP n

8nnnJP Z,n

..

if Z = 1, JP n

9nnnJP NC,n

..

if C = 0, JP n

AnnnJP C,n

..

if C = 1, JP n

BnnnCALL n

..

PC -> (top of stack),  cs++, n*2 -> PC

CnnnCALL NZ,n

..

if Z = 0, CALL n

DnnnCALL Z,n

..

if Z = 1, CALL n

EnnnCALL NC,n

..

if C = 0, CALL n

FnnnCALL C,n

..

if C = 1, CALL n