support negative offset
This commit is contained in:
parent
bcd1500f9c
commit
cad6ed9604
8
vm/vm.c
8
vm/vm.c
@ -154,8 +154,8 @@ void vm_start(Drive* boot_drive, IODevice* io_device)
|
|||||||
uint16_t addr;
|
uint16_t addr;
|
||||||
if (addr_is_reg) {
|
if (addr_is_reg) {
|
||||||
Reg reg = is_store ? ins_dst_reg(ins) : ins_op2_reg(ins);
|
Reg reg = is_store ? ins_dst_reg(ins) : ins_op2_reg(ins);
|
||||||
uint16_t offset = eat_uint16(vm);
|
int16_t offset = (int16_t)eat_uint16(vm);
|
||||||
addr = vm->regs[reg] + offset;
|
addr = (uint16_t)((int16_t)vm->regs[reg] + offset);
|
||||||
} else {
|
} else {
|
||||||
addr = eat_uint16(vm);
|
addr = eat_uint16(vm);
|
||||||
}
|
}
|
||||||
@ -186,8 +186,8 @@ void vm_start(Drive* boot_drive, IODevice* io_device)
|
|||||||
uint16_t addr;
|
uint16_t addr;
|
||||||
if (addr_is_reg) {
|
if (addr_is_reg) {
|
||||||
Reg reg = is_store ? ins_dst_reg(ins) : ins_op2_reg(ins);
|
Reg reg = is_store ? ins_dst_reg(ins) : ins_op2_reg(ins);
|
||||||
uint16_t offset = eat_uint16(vm);
|
int16_t offset = (int16_t)eat_uint16(vm);
|
||||||
addr = vm->regs[reg] + offset;
|
addr = (uint16_t)((int16_t)vm->regs[reg] + offset);
|
||||||
} else {
|
} else {
|
||||||
addr = eat_uint16(vm);
|
addr = eat_uint16(vm);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user