mirror of
https://github.com/dschmenk/PLASMA.git
synced 2024-08-31 13:29:30 +00:00
Page:
PLASMA Byte Codes
Pages
CATalog files
COPY files
Chat Client Server
Command Line Argument Parsing
Console I O
DELete fles
Double Lo Res Graphics
Double Lo Res Test
Fiber Threads
File I O
Game Port SPI I O
Game Port SPI SD FAT
Game Port Wiring
HTTP Server
Hello World
Hi Res Graphics
Hi Res Test
Home
Installation Guide
Joystick and Buzz
Lo Res Graphics Library
Long Jump
Memory Manager
Music Player
Music Sequencer
NEWDIR
Network I O
PLASM compiler
PLASMA Byte Codes
PLASMA JIT Compiler Implementation
Porting Guide
REName files
ROGUE
RPN Calculator
Rod's Colors
SANE Floating Point
Sieve
System Library
TYPE file
Trivial FTP Daemon
Variable assignment and addressing explained
ZIPCHIP
Zero Page Usage (Apple IIe 64K )
code text Editor
5
PLASMA Byte Codes
David Schmenk edited this page 2018-04-16 06:34:03 -07:00
The compact code representation comes through the use of opcodes closely matched to the PLASMA compiler.
TOS: Top Of Stack value
NOS: Next On Stack value (TOS-1)
OPCODE | Name | Description | Operation |
---|---|---|---|
$00-$1F | CN | Constant Nybble | OPCODE/2 ==> TOS |
$20 | MINUS_ONE | constant -1 | -1 ==> TOS |
$22 | BREQ | Branch EQual | NOS == TOS ?? IP = IP + OFFSET |
$24 | BRNE | Branch Not Equal | NOS <> TOS ?? IP = IP + OFFSET |
$26 | LA | Load Address | ABSOLUTE ADDR ==> TOS |
$28 | LLA | Load Local Address | LOCAL ADDR ==> TOS |
$2A | CB | Constant Byte | CONSTANT BYTE ==> TOS |
$2C | CW | Constant Word | CONSTANT WORD ==> TOS |
$2E | CS | Constant String | STRING ADDR ==> TOS |
$30 | DROP | DROP top value | TOS ==> |
$32 | DROP2 | DROP top 2 values | NOS, TOS ==> |
$34 | DUP | DUPlicate top value | TOS ==> TOS |
$36 | DIVMOD | DIVide & MOD tos,nos | NOS / TOS ==> TOS, NOS % TOS ==> NOS |
$38 | ADDI | ADD Immediate byte | TOS + IMM8 ==> TOS |
$3A | SUBI | SUB Immediate byte | TOS - IMM8 ==> TOS |
$3C | ANDI | AND Immediate byte | TOS & IMM8 ==> TOS |
$3E | ORI | OR Immediate byte | TOS | IMM8 ==> TOS |
$40 | ISEQ | IS nos EQual tos | NOS == TOS ==> TOS |
$42 | ISNE | IS nos Not Equal to tos | NOS <> TOS ==> TOS |
$44 | ISGT | IS nos Greater Than tos | NOS > TOS ==> TOS |
$46 | ISLT | IS nos Less Than tos | NOS < TOS ==> TOS |
$48 | ISGE | IS nos Greater or Equal to tos | NOS >= TOS ==> TOS |
$4A | ISLE | IS nos Less or Equal to tos | NOS <= TOS ==> TOS |
$4C | BRFLS | BRanch FaLSe | TOS == 0 ?? IP = IP + OFFSET |
$4E | BRTRU | BRanch TRUe | TOS <> 0 ?? IP = IP + OFFSET |
$50 | BRNCH | BRaNCH | IP = IP + OFFSET |
$52 | SEL | SELect cases | TOS == CASE ?? IP = IP + OFFSET (FOR ALL CASES) |
$54 | CALL | CALL address | PUSH(IP+2), IP = ADDRESS |
$56 | ICAL | Indirect CALl | PUSH(IP+2), IP = TOS |
$58 | ENTER | ENTER frame size, param count | FP = FP - FRAME SIZE, PARAMS ==> LOCALS |
$5A | LEAVE | LEAVE frame size | FP = FP + FRAME SIZE, IP = PULL() |
$5C | RET | RETurn | IP = PULL() |
$5E | CFFB | Constant $FF Byte | CONSTANT BYTE + $FF00 ==> TOS |
$60 | LB | Load Byte | (TOS) ==> TOS |
$62 | LW | Load Word | (TOS) ==> TOS |
$64 | LLB | Load Local Byte | FP[LOCAL] ==> TOS |
$66 | LLW | Load Local Word | FP[LOCAL] ==> TOS |
$68 | LAB | Load Absolute Byte | MEM[ADDR] ==> TOS |
$6A | LAW | Load Absolute Word | MEM[ADDR] ==> TOS |
$6C | DLB | Duplicate to Local Byte | TOS ==> FP[LOCAL], TOS ==> TOS |
$6E | DLW | Duplicate to Local Word | TOS ==> FP[LOCAL], TOS ==> TOS |
$70 | SB | Store Byte | NOS ==> (TOS) |
$72 | SW | Store Word | NOS ==> (TOS) |
$74 | SLB | Store Local Byte | TOS ==> FP[LOCAL] |
$76 | SLW | Store Local Word | TOS ==> FP[LOCAL] |
$78 | SAB | Store Absolute Byte | TOS ==> MEM[ADDR] |
$7A | SAW | Store Absolute Word | TOS ==> MEM[ADDR] |
$7C | DAB | Duplicate to Absolute Byte | TOS ==> MEM[ADDR], TOS ==> TOS |
$7E | DAW | Duplicate to Absolute Word | TOS ==> MEM[ADDR], TOS ==> TOS |
$80 | NOT | logical NOT | !TOS ==> TOS |
$82 | ADD | ADD nos to tos | NOS + TOS ==> TOS |
$84 | SUB | SUBtract tos from nos | NOS - TOS ==> TOS |
$86 | MUL | MULtiply nos times tos | NOS * TOS ==> TOS |
$88 | DIV | DIVide nos by tos | NOS / TOS ==> TOS |
$8A | MOD | MODulo nos by tos | NOS % TOS ==> TOS |
$8C | INCR | INCRement tos | TOS + 1 ==> TOS |
$8E | DECR | DECRement tos | TOS - 1 ==> TOS |
$90 | NEG | NEGate tos | -TOS ==> TOS |
$92 | COMP | COMPliment tos | ~TOS ==> TOS |
$94 | AND | bitwise AND | NOS & TOS ==> TOS |
$96 | IOR | bitwise Inclusive OR | NOS | TOS ==> TOS |
$98 | XOR | bitwise eXclusive OR | NOS ^ TOS ==> TOS |
$9A | SHL | SHift Left | NOS << TOS ==> TOS |
$9C | SHR | SHift Right | NOS >> TOS ==> TOS |
$9E | IDXW | InDeX Word | TOS * 2 + NOS ==> TOS |
$A0 | BRGT | BRanch GReater than (FOR/NEXT) | TOS > NOS ?? IP = IP + OFFSET |
$A2 | BRLT | BRanch Less Than (FOR/NEXT) | TOS < NOS ?? IP = IP + OFFSET |
$A4 | INCBRLE | INCrement, BRanch Less Equal (FOR/NEXT) | TOS + 1 ==> TOS, TOS <= NOS ?? IP = IP + OFFSET |
$A6 | ADDBRLE | ADD, BRanch Less Equal (FOR/NEXT) | NOS + TOS ==> TOS, TOS <= NOS ?? IP = IP + OFFSET |
$A8 | DECBRGE | DECrement, BRanch Greater Equal (FOR/NEXT) | TOS - 1 ==> TOS, TOS >= NOS ?? IP = IP + OFFSET |
$AA | SUBBRGE | SUBtract, BRanch GReater Equal (FOR/NEXT) | NOS = TOS ==> TOS, TOS >= NOS :: IP = IP + OFFSET |
$AC | BRAND | BRanch AND (SHORT CIRCUIT) | TOS == 0 ?? IP = IP + OFFSET :: TOS ==> TOS |
$AE | BROR | BRanch OR (SHORT CIRCUIT) | TOS <> 0 ?? IP = IP + OFFSET :: TOS ==> TOS |
$B0 | ADDLB | ADD Local Byte | TOS + FP[LOCAL] ==> TOS |
$B2 | ADDLW | ADD Local Word | TOS + FP[LOCAL] ==> TOS |
$B4 | ADDAB | ADD Absolute Byte | TOS + MEM[ADDR] ==> TOS |
$B6 | ADDAW | ADD Absolute Word | TOS + MEM[ADDR] ==> TOS |
$B8 | IDXLB | INDeX word by Local Byte | TOS + FP[LOCAL] * 2 ==> TOS |
$BA | IDXLW | INDeX word by Local Word | TOS + FP[LOCAL] * 2 ==> TOS |
$BC | IDXAB | INDeX word by Absolute Byte | TOS + MEM[ADDR] * 2 ==> TOS |
$BE | IDXAW | INDeX word by Absolute Word | TOS + MEM[ADDR] * 2 ==> TOS |
$C0 | NATV | back to in-line NATiVe code | JUMP (IP) |
Bytecode interpreters: 6502, 65802
Bytecode compilers: 6502, 65802, Just-In-Time Compiler Implementation