Add IDiv instruction for signed integer division

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-02-25 13:44:03 -05:00
parent 5619c9dc87
commit 795a890502
7 changed files with 34 additions and 9 deletions

View File

@@ -26,15 +26,16 @@ instructions! {
SUB = 0x0001,
MUL = 0x0002,
DIV = 0x0003,
MOD = 0x0004,
AND = 0x0005,
OR = 0x0006,
XOR = 0x0007,
SHL = 0x0008,
SHR = 0x0009,
INEG = 0x000a,
INV = 0x000b,
NOT = 0x000c,
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,
@@ -52,6 +53,7 @@ pub enum Inst {
Sub(Dest, Source),
Mul(Dest, Source),
Div(Dest, Source),
IDiv(Dest, Source),
Mod(Dest, Source),
And(Dest, Source),
Or(Dest, Source),
@@ -79,6 +81,7 @@ impl Inst {
Inst::Sub(_, _) => SUB,
Inst::Mul(_, _) => MUL,
Inst::Div(_, _) => DIV,
Inst::IDiv(_, _) => IDIV,
Inst::Mod(_, _) => MOD,
Inst::And(_, _) => AND,
Inst::Or(_, _) => OR,
@@ -106,6 +109,7 @@ impl Inst {
| Inst::Sub(dest, source)
| Inst::Mul(dest, source)
| Inst::Div(dest, source)
| Inst::IDiv(dest, source)
| Inst::Mod(dest, source)
| Inst::And(dest, source)
| Inst::Or(dest, source)