fix: correctly add displacement for short jumps

This commit is contained in:
2025-05-20 10:12:13 +09:00
parent cb924af0fb
commit fd15e57569
2 changed files with 16 additions and 4 deletions

View File

@@ -634,12 +634,24 @@ impl Disassembler {
0xE8 => Mnemonic::CALL_v(self.parse_word()),
0xE9 => Mnemonic::JMP_v(self.parse_word()),
// add to address of next instruction
0xE9 => {
// first interpret as IByte, then cast for addition
let word = self.parse_word() as IByte as isize;
let next_addr = (self.offset + 1) as isize;
Mnemonic::JMP_v(next_addr + word)
}
0xEA => Mnemonic::JMP_p(Pointer {
segment: self.parse_word(),
offset: self.parse_word(),
}),
0xEB => Mnemonic::JMP_b(self.parse_byte()),
// add to address of next instruction
0xEB => {
// first interpret as IByte, then cast for addition
let byte = self.parse_byte() as IByte as isize;
let next_addr = (self.offset + 1) as isize;
Mnemonic::JMP_b(next_addr + byte)
}
0xEC => Mnemonic::IN_ALDX,
0xED => Mnemonic::IN_AXDX,