🐛 bug: fix loader bug
parent
2f676adc19
commit
062c6e6a2d
|
@ -43,13 +43,17 @@ pub (crate) fn compile_bytecode (source: Vec <u8>) -> Vec <u8> {
|
|||
output.stdout.as_slice ().to_vec ()
|
||||
}
|
||||
|
||||
fn i_sb (buf: [u8; 4]) -> Option <i8> {
|
||||
let b = buf [2];
|
||||
i8::try_from (i32::try_from (b).ok ()? - 127).ok ()
|
||||
}
|
||||
|
||||
pub fn parse_inst (buf: [u8; 4]) -> Option <Inst>
|
||||
{
|
||||
let opcode = buf [0] & 0x7f;
|
||||
|
||||
let a = (buf [0] >> 7) | ((buf [1] & 0x7f) << 1);
|
||||
let b = buf [2];
|
||||
let sb = i8::try_from (b).ok ()? - 127;
|
||||
let ax = a as u32 + ((b as u32) << 8);
|
||||
let c = buf [3];
|
||||
let bx =
|
||||
|
@ -84,7 +88,7 @@ pub fn parse_inst (buf: [u8; 4]) -> Option <Inst>
|
|||
0x30 => Inst::MmBinK (a, b, c, k),
|
||||
0x33 => Inst::Not (a, b),
|
||||
0x3c => Inst::EqK (a, b, k),
|
||||
0x3d => Inst::EqI (a, sb, k),
|
||||
0x3d => Inst::EqI (a, i_sb (buf)?, k),
|
||||
0x38 => Inst::Jmp (s_j),
|
||||
0x42 => Inst::Test (a, k),
|
||||
0x44 => Inst::Call (a, b, c),
|
||||
|
|
Loading…
Reference in New Issue