Change instruction encodings to avoid null instructions

Lots of null bytes in a row are a common thing, so the instructions
available can't start with a null pair of bytes anymore.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-03-09 15:11:32 -04:00
parent b697b000a4
commit 65972fcbbe
6 changed files with 54 additions and 56 deletions

View File

@@ -21,7 +21,7 @@
jnz end
mov %status, $1
end:
div %r0, $0
int $0, $0
halt
.export main

View File

@@ -23,32 +23,32 @@ macro_rules! instructions {
pub type InstOp = u16;
instructions! {
ADD = 0x0000,
SUB = 0x0001,
MUL = 0x0002,
DIV = 0x0003,
IDIV = 0x0004,
MOD = 0x0005,
AND = 0x0006,
OR = 0x0007,
XOR = 0x0008,
SHL = 0x0009,
SHR = 0x000a,
INEG = 0x000b,
INV = 0x000c,
NOT = 0x000d,
CMPEQ = 0x1000,
CMPLT = 0x1001,
JMP = 0x1002,
JZ = 0x1003,
JNZ = 0x1004,
CALL = 0x2000,
RET = 0x2001,
PUSH = 0x2002,
POP = 0x2003,
INT = 0x2004,
IRET = 0x2005,
MOV = 0x3000,
ADD = 0x1000,
SUB = 0x1001,
MUL = 0x1002,
DIV = 0x1003,
IDIV = 0x1004,
MOD = 0x1005,
AND = 0x1006,
OR = 0x1007,
XOR = 0x1008,
SHL = 0x1009,
SHR = 0x100a,
INEG = 0x100b,
INV = 0x100c,
NOT = 0x100d,
CMPEQ = 0x2000,
CMPLT = 0x2001,
JMP = 0x2002,
JZ = 0x2003,
JNZ = 0x2004,
CALL = 0x3000,
RET = 0x3001,
PUSH = 0x3002,
POP = 0x3003,
INT = 0x3004,
IRET = 0x3005,
MOV = 0x4000,
HALT = 0xF000,
NOP = 0xF001,
DUMP = 0xF002,

View File

@@ -1,5 +1,4 @@
use crate::{
addr::Addr,
obj::{
assemble::{
Asm,

View File

@@ -1,4 +1,4 @@
use crate::{mem::MemCursor, obj::obj::*, inst::Inst};
use crate::{mem::MemCursor, obj::obj::*};
use prettytable::{Table, row, cell};
use std::io::{self, Write as Write};