🐛 bug: impl opcodes
parent
1943f0a40b
commit
e59dd85246
|
@ -52,6 +52,8 @@ pub enum Instruction {
|
||||||
// MetaMethod, Binary
|
// MetaMethod, Binary
|
||||||
MmBin (u8, u8, u8),
|
MmBin (u8, u8, u8),
|
||||||
|
|
||||||
|
MmBinI (u8, i8, u8, bool),
|
||||||
|
|
||||||
MmBinK (u8, u8, u8, bool),
|
MmBinK (u8, u8, u8, bool),
|
||||||
|
|
||||||
ModK (u8, u8, u8),
|
ModK (u8, u8, u8),
|
||||||
|
@ -82,6 +84,8 @@ pub enum Instruction {
|
||||||
|
|
||||||
SetTabUp (u8, u8, u8),
|
SetTabUp (u8, u8, u8),
|
||||||
|
|
||||||
|
Sub (u8, u8, u8),
|
||||||
|
|
||||||
TailCall (u8, u8, u8, bool),
|
TailCall (u8, u8, u8, bool),
|
||||||
|
|
||||||
Test (u8, bool),
|
Test (u8, bool),
|
||||||
|
|
|
@ -84,7 +84,6 @@ pub fn parse_inst (buf: [u8; 4]) -> Option <Inst>
|
||||||
let b = buf [2];
|
let b = buf [2];
|
||||||
let ax = a as u32 + ((b as u32) << 8);
|
let ax = a as u32 + ((b as u32) << 8);
|
||||||
let c = buf [3];
|
let c = buf [3];
|
||||||
let s_c = c - 0x80;
|
|
||||||
let bx =
|
let bx =
|
||||||
(((buf [1] >> 7) as u32) << 0) |
|
(((buf [1] >> 7) as u32) << 0) |
|
||||||
((buf [2] as u32) << 1) |
|
((buf [2] as u32) << 1) |
|
||||||
|
@ -114,8 +113,10 @@ pub fn parse_inst (buf: [u8; 4]) -> Option <Inst>
|
||||||
0x18 => Inst::MulK (a, b, c),
|
0x18 => Inst::MulK (a, b, c),
|
||||||
0x19 => Inst::ModK (a, b, c),
|
0x19 => Inst::ModK (a, b, c),
|
||||||
0x22 => Inst::Add (a, b, c),
|
0x22 => Inst::Add (a, b, c),
|
||||||
|
0x23 => Inst::Sub (a, b, c),
|
||||||
0x24 => Inst::Mul (a, b, c),
|
0x24 => Inst::Mul (a, b, c),
|
||||||
0x2e => Inst::MmBin (a, b, c),
|
0x2e => Inst::MmBin (a, b, c),
|
||||||
|
0x2f => Inst::MmBinI (a, i_sb (buf)?, c, k),
|
||||||
0x30 => Inst::MmBinK (a, b, c, k),
|
0x30 => Inst::MmBinK (a, b, c, k),
|
||||||
0x33 => Inst::Not (a, b),
|
0x33 => Inst::Not (a, b),
|
||||||
0x34 => Inst::Len (a, b),
|
0x34 => Inst::Len (a, b),
|
||||||
|
|
19
src/state.rs
19
src/state.rs
|
@ -448,6 +448,9 @@ impl <'a> State <'a> {
|
||||||
panic! ("Not sure how to implememtn OP_MMBIN for these 2 values {a:?}, {b:?}");
|
panic! ("Not sure how to implememtn OP_MMBIN for these 2 values {a:?}, {b:?}");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Instruction::MmBinI (_a, _s_b, _c, _k) => {
|
||||||
|
// Ignore
|
||||||
|
},
|
||||||
Instruction::MmBinK (_a, _b, _c, _k) => {
|
Instruction::MmBinK (_a, _b, _c, _k) => {
|
||||||
// Ignore
|
// Ignore
|
||||||
},
|
},
|
||||||
|
@ -633,6 +636,22 @@ impl <'a> State <'a> {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Instruction::SetTabUp (_a, _b, _c) => unimplemented! (),
|
Instruction::SetTabUp (_a, _b, _c) => unimplemented! (),
|
||||||
|
Instruction::Sub (a, b, c) => {
|
||||||
|
let v_b = self.reg (*b);
|
||||||
|
let v_c = self.reg (*c);
|
||||||
|
|
||||||
|
let x = if let (Some (v_b), Some (v_c)) = (v_b.as_int (), v_c.as_int ())
|
||||||
|
{
|
||||||
|
Value::from (v_b - v_c)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let v_b = v_b.as_float ().unwrap_or_else (|| panic! ("{v_b}"));
|
||||||
|
let v_c = v_c.as_float ().unwrap_or_else (|| panic! ("{v_c}"));
|
||||||
|
Value::from (v_b - v_c)
|
||||||
|
};
|
||||||
|
|
||||||
|
*self.reg_mut (*a) = x;
|
||||||
|
},
|
||||||
Instruction::TailCall (a, b, _c, k) => {
|
Instruction::TailCall (a, b, _c, k) => {
|
||||||
assert! (!k, "closing over values in tail calls not implemented");
|
assert! (!k, "closing over values in tail calls not implemented");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue