[VM] Made the implementation of opcodes letb and letw more correct.

This commit is contained in:
jtuu 2019-10-17 20:02:53 +03:00
parent 4b7e03931c
commit cd52ca4576

View File

@ -248,8 +248,10 @@ export class VirtualMachine {
this.set_register_signed(arg0, arg1); this.set_register_signed(arg0, arg1);
break; break;
case OP_LETB.code: case OP_LETB.code:
this.set_register_byte(arg0, arg1);
break;
case OP_LETW.code: case OP_LETW.code:
this.set_register_unsigned(arg0, arg1); this.set_register_word(arg0, arg1);
break; break;
case OP_LETA.code: case OP_LETA.code:
this.set_register_unsigned(arg0, this.get_register_address(arg0)); this.set_register_unsigned(arg0, this.get_register_address(arg0));
@ -596,6 +598,22 @@ export class VirtualMachine {
this.registers.write_u32_at(REGISTER_SIZE * reg, value); this.registers.write_u32_at(REGISTER_SIZE * reg, value);
} }
public get_register_word(reg: number): number {
return this.registers.u16_at(REGISTER_SIZE * reg);
}
private set_register_word(reg: number, value: number): void {
this.registers.write_u16_at(REGISTER_SIZE * reg, value);
}
public get_register_byte(reg: number): number {
return this.registers.u8_at(REGISTER_SIZE * reg);
}
public set_register_byte(reg: number, value: number): void {
this.registers.write_u8_at(REGISTER_SIZE * reg, value)
}
public get_register_float(reg: number): number { public get_register_float(reg: number): number {
return this.registers.f32_at(REGISTER_SIZE * reg); return this.registers.f32_at(REGISTER_SIZE * reg);
} }