From 4bf74d76644f8ce036edf987a6a6438be27fc612 Mon Sep 17 00:00:00 2001 From: IniKiwi Date: Tue, 16 Aug 2022 11:03:40 +0200 Subject: [PATCH] bugfixs in movw opcodes --- src/instructions/movw.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/instructions/movw.c b/src/instructions/movw.c index edce55b..8d6885d 100644 --- a/src/instructions/movw.c +++ b/src/instructions/movw.c @@ -2,13 +2,13 @@ #include void instruction_movw_r0_disp_r(cpu_status_t* status){ - long disp = (0x0000000F & (long)status->r[LO_NIBBLE(cpu_read8(status,status->pc+1))]); + long disp = (0x0000000F & (long)LO_NIBBLE(cpu_read8(status,status->pc+1))); cpu_write16(status, status->r[HI_NIBBLE(cpu_read8(status,status->pc+1))] + (disp << 1), status->r[0]); status->pc += 2; } void instruction_movw_disp_r_r0(cpu_status_t* status){ - long disp = (0x0000000F & (long)status->r[LO_NIBBLE(cpu_read8(status,status->pc+1))]); + long disp = (0x0000000F & (long)LO_NIBBLE(cpu_read8(status,status->pc+1))); status->r[0] = cpu_read16(status, status->r[HI_NIBBLE(cpu_read8(status,status->pc+1))] + (disp << 1)); if ((status->r[0] & 0x8000) == 0) @@ -91,6 +91,6 @@ void instruction_movw_disp_gbr_r0(cpu_status_t* status){ } void instruction_movw_r_r0_r(cpu_status_t* status){ - cpu_write16(status, status->r[LO_NIBBLE(cpu_read8(status,status->pc))] + status->r[0], status->r[LO_NIBBLE(cpu_read8(status,status->pc))]); + cpu_write16(status, status->r[LO_NIBBLE(cpu_read8(status,status->pc))] + status->r[0], status->r[HI_NIBBLE(cpu_read8(status,status->pc+1))]); status->pc += 2; }