Fix execution of instructions with two literals
This commit is contained in:
parent
4127d9bde8
commit
9cb338f83e
14
dsim.c
14
dsim.c
|
@ -15,7 +15,7 @@
|
||||||
uint16_t ram[0x10000];
|
uint16_t ram[0x10000];
|
||||||
uint16_t ra, rb, rc, rx, ry, rz, ri, rj;
|
uint16_t ra, rb, rc, rx, ry, rz, ri, rj;
|
||||||
uint16_t rpc, rsp, rex, ria;
|
uint16_t rpc, rsp, rex, ria;
|
||||||
uint16_t lit; /* temporary storage for literal operands */
|
uint16_t lit_a, lit_b; /* temporary storage for literal operands */
|
||||||
|
|
||||||
bool skip_next;
|
bool skip_next;
|
||||||
uint64_t ticks;
|
uint64_t ticks;
|
||||||
|
@ -78,6 +78,10 @@ void shutdown()
|
||||||
|
|
||||||
uint16_t *val(int operand, bool is_a)
|
uint16_t *val(int operand, bool is_a)
|
||||||
{
|
{
|
||||||
|
uint16_t *lit;
|
||||||
|
|
||||||
|
lit = (is_a ? &lit_a : &lit_b);
|
||||||
|
|
||||||
switch (operand) {
|
switch (operand) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
return &ra;
|
return &ra;
|
||||||
|
@ -153,11 +157,11 @@ uint16_t *val(int operand, bool is_a)
|
||||||
return &ram[ram[rpc++]];
|
return &ram[ram[rpc++]];
|
||||||
case 0x1f:
|
case 0x1f:
|
||||||
ticks++;
|
ticks++;
|
||||||
lit = ram[rpc++];
|
*lit = ram[rpc++];
|
||||||
return &lit;
|
return lit;
|
||||||
default:
|
default:
|
||||||
lit = operand - 0x21;
|
*lit = operand - 0x21;
|
||||||
return &lit;
|
return lit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue