Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-02-09 13:13:26 -05:00
parent 1c16be650a
commit f1ed41f98b
11 changed files with 44 additions and 75 deletions

View File

@@ -10,7 +10,6 @@ macro_rules! instructions {
}
pub type InstOp = u16;
instructions! {
ADD = 0x0000,
MUL = 0x0001,
@@ -42,30 +41,10 @@ instructions! {
pub fn inst_len(op: InstOp) -> usize {
match op {
// 2 bytes
INEG
| INV
| NOT
| HALT
| NOP => 2,
INEG | INV | NOT | HALT | NOP => 2,
// 4 bytes
ADD
| MUL
| DIV
| MOD
| AND
| OR
| XOR
| SHL
| SHR
| CMPEQ
| CMPLT
| JMP
| JZ
| JNZ
| LOAD
| REGCOPY
| MEMCOPY
| STORE => 4,
ADD | MUL | DIV | MOD | AND | OR | XOR | SHL | SHR | CMPEQ | CMPLT | JMP | JZ | JNZ
| LOAD | REGCOPY | MEMCOPY | STORE => 4,
// Immediates - 4+ bytes
STOREIMM64 => 16,
STOREIMM32 => 8,