mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-08-10 22:25:03 +00:00
Update Architecture.md
This commit is contained in:
@@ -19,70 +19,71 @@ One of the biggest problems to overcome with the 6502 is its very small hardware
|
|||||||
### The Bytecodes
|
### The Bytecodes
|
||||||
The compact code representation comes through the use of opcodes closely matched to the PLASMA compiler. They are:
|
The compact code representation comes through the use of opcodes closely matched to the PLASMA compiler. They are:
|
||||||
|
|
||||||
| OPCODE | Description
|
| OPCODE | Name | Description
|
||||||
|:------:|-----------------------------------
|
|:------:|:------:|-----------------------------------
|
||||||
| ZERO | push zero on the stack
|
| $00 | ZERO | push zero on the stack
|
||||||
| ADD | add top two values, leave result on top
|
| $02 | ADD | add top two values, leave result on top
|
||||||
| SUB | subtract next from top from top, leave result on top
|
| $04 | SUB | subtract next from top from top, leave result on top
|
||||||
| MUL | multiply two topmost stack values, leave result on top
|
| $06 | MUL | multiply two topmost stack values, leave result on top
|
||||||
| DIV | divide next from top by top, leave result on top
|
| $08 | DIV | divide next from top by top, leave result on top
|
||||||
| MOD | divide next from top by top, leave remainder on top
|
| $0A | MOD | divide next from top by top, leave remainder on top
|
||||||
| INCR | increment top of stack
|
| $0C | INCR | increment top of stack
|
||||||
| DECR | decrement top of stack
|
| $0E | DECR | decrement top of stack
|
||||||
| NEG | negate top of stack
|
| $10 | NEG | negate top of stack
|
||||||
| COMP | compliment top of stack
|
| $12 | COMP | compliment top of stack
|
||||||
| AND | bit wise AND top two values, leave result on top
|
| $14 | AND | bit wise AND top two values, leave result on top
|
||||||
| IOR | bit wise inclusive OR top two values, leave result on top
|
| $16 | IOR | bit wise inclusive OR top two values, leave result on top
|
||||||
| XOR | bit wise exclusive OR top two values, leave result on top
|
| $18 | XOR | bit wise exclusive OR top two values, leave result on top
|
||||||
| LOR | logical OR top two values, leave result on top
|
| $1A | SHL | shift left next from top by top, leave result on top
|
||||||
| LAND | logical AND top two values, leave result on top
|
| $1C | SHR | shift right next from top by top, leave result on top
|
||||||
| SHL | shift left next from top by top, leave result on top
|
| $02 | IDXB | add top of stack to next from top, leave result on top (ADD)
|
||||||
| SHR | shift right next from top by top, leave result on top
|
| $1E | IDXW | add 2X top of stack to next from top, leave result on top
|
||||||
| IDXB | add top of stack to next from top, leave result on top (ADD)
|
| $20 | NOT | logical NOT of top of stack
|
||||||
| IDXW | add 2X top of stack to next from top, leave result on top
|
| $22 | LOR | logical OR top two values, leave result on top
|
||||||
| NOT | logical NOT of top of stack
|
| $24 | LAND | logical AND top two values, leave result on top
|
||||||
| LA | load address
|
| $26 | LA | load address
|
||||||
| LLA | load local address from frame offset
|
| $28 | LLA | load local address from frame offset
|
||||||
| CB | constant byte
|
| $2A | CB | constant byte
|
||||||
| CW | constant word
|
| $2C | CW | constant word
|
||||||
| SWAP | swap two topmost stack values
|
| $2E | SWAP | swap two topmost stack values
|
||||||
| DROP | drop top stack value
|
| $30 | DROP | drop top stack value
|
||||||
| DUP | duplicate top stack value
|
| $32 | DUP | duplicate top stack value
|
||||||
| PUSH | push top to call stack
|
| $34 | PUSH | push top to call stack
|
||||||
| PULL | pull from call stack
|
| $36 | PULL | pull from call stack
|
||||||
| BRGT | branch next from top greater than top
|
| $38 | BRGT | branch next from top greater than top
|
||||||
| BRLT | branch next from top less than top
|
| $3A | BRLT | branch next from top less than top
|
||||||
| BREQ | branch next from top equal to top
|
| $3C | BREQ | branch next from top equal to top
|
||||||
| BRNE | branch next from top not equal to top
|
| $3E | BRNE | branch next from top not equal to top
|
||||||
| ISEQ | if next from top is equal to top, set top true
|
| $40 | ISEQ | if next from top is equal to top, set top true
|
||||||
| ISNE | if next from top is not equal to top, set top true
|
| $42 | ISNE | if next from top is not equal to top, set top true
|
||||||
| ISGT | if next from top is greater than top, set top true
|
| $44 | ISGT | if next from top is greater than top, set top true
|
||||||
| ISLT | if next from top is less than top, set top true
|
| $46 | ISLT | if next from top is less than top, set top true
|
||||||
| ISGE | if next from top is greater than or equal to top, set top true
|
| $48 | ISGE | if next from top is greater than or equal to top, set top true
|
||||||
| ISLE | if next from top is less than or equal to top, set top true
|
| $4A | ISLE | if next from top is less than or equal to top, set top true
|
||||||
| BRFLS | branch if top of stack is zero
|
| $4C | BRFLS | branch if top of stack is zero
|
||||||
| BRTRU | branch if top of stack is non-zero
|
| $4E | BRTRU | branch if top of stack is non-zero
|
||||||
| BRNCH | branch to address
|
| $50 | BRNCH | branch to address
|
||||||
| CALL | sub routine call with stack parameters
|
| $52 | IBRNCH | branch to address on stack top
|
||||||
| ICAL | sub routine call to indirect address on stack top with stack parameters
|
| $54 | CALL | sub routine call with stack parameters
|
||||||
| ENTER | allocate frame size and copy stack parameters to local frame
|
| $56 | ICAL | sub routine call to address on stack top with stack parameters
|
||||||
| LEAVE | deallocate frame and return from sub routine call
|
| $58 | ENTER | allocate frame size and copy stack parameters to local frame
|
||||||
| RET | return from sub routine call
|
| $5A | LEAVE | deallocate frame and return from sub routine call
|
||||||
| LB | load byte from top of stack address
|
| $5C | RET | return from sub routine call
|
||||||
| LW | load word from top of stack address
|
| $60 | LB | load byte from top of stack address
|
||||||
| LLB | load byte from frame offset
|
| $62 | LW | load word from top of stack address
|
||||||
| LLW | load word from frame offset
|
| $64 | LLB | load byte from frame offset
|
||||||
| LAB | load byte from absolute address
|
| $66 | LLW | load word from frame offset
|
||||||
| LAW | load word from absolute address
|
| $68 | LAB | load byte from absolute address
|
||||||
| SB | store top of stack byte into next from top address
|
| $6A | LAW | load word from absolute address
|
||||||
| SW | store top of stack word into next from top address
|
| $6C | DLB | duplicate top of stack into local byte at frame offset
|
||||||
| SLB | store top of stack into local byte at frame offset
|
| $6E | DLW | duplicate top of stack into local word at frame offset
|
||||||
| SLW | store top of stack into local word at frame offset
|
| $70 | SB | store top of stack byte into next from top address
|
||||||
| SAB | store top of stack into byte at absolute address
|
| $72 | SW | store top of stack word into next from top address
|
||||||
| SAW | store top of stack into word at absolute address
|
| $74 | SLB | store top of stack into local byte at frame offset
|
||||||
| DLB | duplicate top of stack into local byte at frame offset
|
| $76 | SLW | store top of stack into local word at frame offset
|
||||||
| DLW | duplicate top of stack into local word at frame offset
|
| $78 | SAB | store top of stack into byte at absolute address
|
||||||
| DAB | duplicate top of stack into byte at absolute address
|
| $7A | SAW | store top of stack into word at absolute address
|
||||||
| DAW | duplicate top of stack into word at absolute address
|
| $7C | DAB | duplicate top of stack into byte at absolute address
|
||||||
|
| $7E | DAW | duplicate top of stack into word at absolute address
|
||||||
|
|
||||||
The opcodes were developed over time by starting with a very basic set of operations and slowly adding opcodes when the PLASMA compiler could improve code density or performance.
|
The opcodes were developed over time by starting with a very basic set of operations and slowly adding opcodes when the PLASMA compiler could improve code density or performance.
|
||||||
|
Reference in New Issue
Block a user