vasm

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice.
Post Reply
Maniccyberdog
Posts: 11
Joined: 11 Nov 2018, 13:18

vasm

Post by Maniccyberdog » 18 Nov 2018, 17:24

I can see that the website lists the instruction set for the vCPU, is their a doc describing these commands?

bmwtcu
Posts: 4
Joined: 01 Nov 2018, 12:02

Re: vasm

Post by bmwtcu » 18 Nov 2018, 19:37

From https://github.com/kervinck/gigatron-ro ... nguage.txt

Code: Select all

----------------------

vCPU instruction table

----------------------

The vCPU interpreter has 34 core instructions. Each opcode is just

a jump offset into the interpreter code page to the code that

implements its behavior. Most instructions take a single byte

operand, but some have two and others none.



Mnem. Operands Description

----- -------- -----------

ST    $DD      Store byte in zero page ([D]=vAC)

STW   $DD      Store word into zero page ([D]=vAC&255,[D+1]=vAC>>8)

STLW  $DD      Store word in stack frame (vSP[D],vSP[D+1]=vAC&255,vAC>>8)

LD    $DD      Load byte from zero page (vAC=[D])

LDI   $DD      Load immediate small positive constant (vAC=D)

LDWI  $DDDD    Load immediate arbitrary constant (vAC=D)

LDW   $DD      Word load from zero page (vAC=[D]+256*[D+1])

LDLW  $DD      Load word from stack frame (vAC=vSP[D]+256*vSP[D+1])

ADDW  $DD      Word addition with zero page (vAC+=[D]+256*[D+1])

SUBW  $DD      Word subtraction with zero page (vAC-=[D]+256*[D+1])

ADDI  $DD      Add small positive constant (vAC+=D)

SUBI  $DD      Subtract small positive constant (vAC-=D)

LSLW  -        Shift left (because 'ADDW vAC' will not work!) (vAC+=vAC)

INC   $DD      Increment zero page byte ([D]++)

ANDI  $DD      Logical-AND with constant (vAC&=D)

ANDW  $DD      Word logical-AND with zero page (vAC&=[D]+256*[D+1])

ORI   $DD      Logical-OR with constant (vAC|=D)

ORW   $DD      Word logical-OR with zero page (vAC|=[D]+256*[D+1])

XORI  $DD      Logical-XOR with constant (vAC^=D)

XORW  $DD      Word logical-XOR with zero page (vAC^=[D]+256*[D+1])

PEEK  -        Read byte from memory (vAC=[vAC])

DEEK  -        Read word from memory (vAC=[vAC]+256*[vAC+1])

POKE  $DD      Write byte in memory ([[D+1],[D]]=vAC&255)

DOKE  $DD      Write word in memory ([[D+1],[D]],[[D+1],[D]+1]=vAC&255,vAC>>8)

LUP   $DD      ROM lookup (vAC=ROM[D,AC])

BRA   $DD      Branch unconditionally (vPC=(vPC&0xff00)+D)

BCC   $CC $DD  Test vAC and branch conditionally. CC can be EQ,NE,LT,GT,LE,GE

CALL  $DD      Goto address but remember vPC (vLR,vPC=vPC+2,[D]+256*[D+1]-2)

RET   -        Leaf return (vPC=vLR-2)

PUSH  -        Push vLR on stack ([--vSP]=vLR&255,[--vSP]=vLR>>8)

POP   -        Pop value from stack (vAC=[vSP]+256*[vSP+1],vSP+=2)

ALLOC $DD      Create or destroy stack frame (vSP+=D)

SYS   $DD      Native function call using at most 2*T cycles, D=270-max(14,T)

DEF   $DD      Define data or code (vAC,vPC=vPC+2,D+256*(vPC>>8))

Last edited by bmwtcu on 18 Nov 2018, 19:58, edited 1 time in total.

User avatar
marcelk
Posts: 139
Joined: 13 May 2018, 08:26

Re: vasm

Post by marcelk » 18 Nov 2018, 19:38

Maniccyberdog wrote:
18 Nov 2018, 17:24
I can see that the website lists the instruction set for the vCPU, is their a doc describing these commands?
marcelk wrote:The GCL notation is documented in Docs/GCL-language.txt. The same document also describes the vCPU instruction set if you scroll down a bit.

Code: Select all

----------------------
vCPU instruction table
----------------------
The vCPU interpreter has 34 core instructions. Each opcode is just
a jump offset into the interpreter code page to the code that
implements its behavior. Most instructions take a single byte
operand, but some have two and others none.

Mnem. Operands Description
----- -------- -----------
ST    $DD      Store byte in zero page ([D]=vAC)
STW   $DD      Store word into zero page ([D]=vAC&255,[D+1]=vAC>>8)
STLW  $DD      Store word in stack frame (vSP[D],vSP[D+1]=vAC&255,vAC>>8)
LD    $DD      Load byte from zero page (vAC=[D])
LDI   $DD      Load immediate small positive constant (vAC=D)
LDWI  $DDDD    Load immediate arbitrary constant (vAC=D)
LDW   $DD      Word load from zero page (vAC=[D]+256*[D+1])
LDLW  $DD      Load word from stack frame (vAC=vSP[D]+256*vSP[D+1])
ADDW  $DD      Word addition with zero page (vAC+=[D]+256*[D+1])
SUBW  $DD      Word subtraction with zero page (vAC-=[D]+256*[D+1])
ADDI  $DD      Add small positive constant (vAC+=D)
SUBI  $DD      Subtract small positive constant (vAC-=D)
LSLW  -        Shift left (because 'ADDW vAC' will not work!) (vAC+=vAC)
INC   $DD      Increment zero page byte ([D]++)
ANDI  $DD      Logical-AND with constant (vAC&=D)
ANDW  $DD      Word logical-AND with zero page (vAC&=[D]+256*[D+1])
ORI   $DD      Logical-OR with constant (vAC|=D)
ORW   $DD      Word logical-OR with zero page (vAC|=[D]+256*[D+1])
XORI  $DD      Logical-XOR with constant (vAC^=D)
XORW  $DD      Word logical-XOR with zero page (vAC^=[D]+256*[D+1])
PEEK  -        Read byte from memory (vAC=[vAC])
DEEK  -        Read word from memory (vAC=[vAC]+256*[vAC+1])
POKE  $DD      Write byte in memory ([[D+1],[D]]=vAC&255)
DOKE  $DD      Write word in memory ([[D+1],[D]],[[D+1],[D]+1]=vAC&255,vAC>>8)
LUP   $DD      ROM lookup (vAC=ROM[D,AC])
BRA   $DD      Branch unconditionally (vPC=(vPC&0xff00)+D)
BCC   $CC $DD  Test vAC and branch conditionally. CC can be EQ,NE,LT,GT,LE,GE
CALL  $DD      Goto address but remember vPC (vLR,vPC=vPC+2,[D]+256*[D+1]-2)
RET   -        Leaf return (vPC=vLR-2)
PUSH  -        Push vLR on stack ([--vSP]=vLR&255,[--vSP]=vLR>>8)
POP   -        Pop value from stack (vAC=[vSP]+256*[vSP+1],vSP+=2)
ALLOC $DD      Create or destroy stack frame (vSP+=D)
SYS   $DD      Native function call using at most 2*T cycles, D=270-max(14,T)
DEF   $DD      Define data or code (vAC,vPC=vPC+2,D+256*(vPC>>8))
The addresses / magic constants are defined in interface.json

For example, the implementation for RET starts at 0x03ff, so its opcode is 0xff.

Maniccyberdog
Posts: 11
Joined: 11 Nov 2018, 13:18

Re: vasm

Post by Maniccyberdog » 18 Nov 2018, 22:11

Thanks, I knew I had seen it somewhere

Post Reply