Update sto/ldo implementations with 16 bit offsets

This commit is contained in:
Anthony Green 2014-12-27 18:19:49 -05:00
parent bffb60047d
commit 507411ccab
2 changed files with 38 additions and 26 deletions

View File

@ -1,3 +1,9 @@
2014-12-27 Anthony Green <green@moxielogic.com>
* interp.c (EXTRACT_OFFSET): Define.
(sim_resume): ldo/sto instructions now use 16 bit offset instead
of 32. Also swap mul.x/umul.x opcodes (reversed by mistake).
2014-12-25 Anthony Green <green@moxielogic.com>
* interp.c (sim_resume): Whitespace changes to align with GDB

View File

@ -50,6 +50,12 @@ FILE *tracefile;
+ (sim_core_read_aligned_1 (scpu, cia, read_map, addr+2) << 8) \
+ (sim_core_read_aligned_1 (scpu, cia, read_map, addr+3)))
#define EXTRACT_OFFSET(addr) \
(unsigned int) \
(((signed short) \
((sim_core_read_aligned_1 (scpu, cia, read_map, addr) << 8) \
+ (sim_core_read_aligned_1 (scpu, cia, read_map, addr+1))) << 16) >> 16)
unsigned long
moxie_extract_unsigned_integer (addr, len)
unsigned char * addr;
@ -555,26 +561,26 @@ sim_resume (sd, step, siggnal)
break;
case 0x0c: /* ldo.l */
{
unsigned int addr = EXTRACT_WORD(pc+2);
unsigned int addr = EXTRACT_OFFSET(pc+2);
int a = (inst >> 4) & 0xf;
int b = inst & 0xf;
TRACE("ldo.l");
addr += cpu.asregs.regs[b];
cpu.asregs.regs[a] = rlat (scpu, opc, addr);
pc += 4;
pc += 2;
}
break;
case 0x0d: /* sto.l */
{
unsigned int addr = EXTRACT_WORD(pc+2);
unsigned int addr = EXTRACT_OFFSET(pc+2);
int a = (inst >> 4) & 0xf;
int b = inst & 0xf;
TRACE("sto.l");
addr += cpu.asregs.regs[a];
wlat (scpu, opc, addr, cpu.asregs.regs[b]);
pc += 4;
pc += 2;
}
break;
case 0x0e: /* cmp */
@ -641,20 +647,7 @@ sim_resume (sd, step, siggnal)
cpu.asregs.regs[a] = (int) bv & 0xffff;
}
break;
case 0x14: /* mul.x */
{
int a = (inst >> 4) & 0xf;
int b = inst & 0xf;
unsigned av = cpu.asregs.regs[a];
unsigned bv = cpu.asregs.regs[b];
signed long long r =
(signed long long) av * (signed long long) bv;
TRACE("mul.x");
cpu.asregs.regs[a] = r >> 32;
}
break;
case 0x15: /* umul.x */
case 0x14: /* umul.x */
{
int a = (inst >> 4) & 0xf;
int b = inst & 0xf;
@ -667,6 +660,19 @@ sim_resume (sd, step, siggnal)
cpu.asregs.regs[a] = r >> 32;
}
break;
case 0x15: /* mul.x */
{
int a = (inst >> 4) & 0xf;
int b = inst & 0xf;
unsigned av = cpu.asregs.regs[a];
unsigned bv = cpu.asregs.regs[b];
signed long long r =
(signed long long) av * (signed long long) bv;
TRACE("mul.x");
cpu.asregs.regs[a] = r >> 32;
}
break;
case 0x16: /* bad */
case 0x17: /* bad */
case 0x18: /* bad */
@ -1057,50 +1063,50 @@ sim_resume (sd, step, siggnal)
break;
case 0x36: /* ldo.b */
{
unsigned int addr = EXTRACT_WORD(pc+2);
unsigned int addr = EXTRACT_OFFSET(pc+2);
int a = (inst >> 4) & 0xf;
int b = inst & 0xf;
TRACE("ldo.b");
addr += cpu.asregs.regs[b];
cpu.asregs.regs[a] = rbat (scpu, opc, addr);
pc += 4;
pc += 2;
}
break;
case 0x37: /* sto.b */
{
unsigned int addr = EXTRACT_WORD(pc+2);
unsigned int addr = EXTRACT_OFFSET(pc+2);
int a = (inst >> 4) & 0xf;
int b = inst & 0xf;
TRACE("sto.b");
addr += cpu.asregs.regs[a];
wbat (scpu, opc, addr, cpu.asregs.regs[b]);
pc += 4;
pc += 2;
}
break;
case 0x38: /* ldo.s */
{
unsigned int addr = EXTRACT_WORD(pc+2);
unsigned int addr = EXTRACT_OFFSET(pc+2);
int a = (inst >> 4) & 0xf;
int b = inst & 0xf;
TRACE("ldo.s");
addr += cpu.asregs.regs[b];
cpu.asregs.regs[a] = rsat (scpu, opc, addr);
pc += 4;
pc += 2;
}
break;
case 0x39: /* sto.s */
{
unsigned int addr = EXTRACT_WORD(pc+2);
unsigned int addr = EXTRACT_OFFSET(pc+2);
int a = (inst >> 4) & 0xf;
int b = inst & 0xf;
TRACE("sto.s");
addr += cpu.asregs.regs[a];
wsat (scpu, opc, addr, cpu.asregs.regs[b]);
pc += 4;
pc += 2;
}
break;
default: