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 ra, rb, rc, rx, ry, rz, ri, rj;
|
||||
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;
|
||||
uint64_t ticks;
|
||||
|
@ -78,6 +78,10 @@ void shutdown()
|
|||
|
||||
uint16_t *val(int operand, bool is_a)
|
||||
{
|
||||
uint16_t *lit;
|
||||
|
||||
lit = (is_a ? &lit_a : &lit_b);
|
||||
|
||||
switch (operand) {
|
||||
case 0x00:
|
||||
return &ra;
|
||||
|
@ -153,11 +157,11 @@ uint16_t *val(int operand, bool is_a)
|
|||
return &ram[ram[rpc++]];
|
||||
case 0x1f:
|
||||
ticks++;
|
||||
lit = ram[rpc++];
|
||||
return &lit;
|
||||
*lit = ram[rpc++];
|
||||
return lit;
|
||||
default:
|
||||
lit = operand - 0x21;
|
||||
return &lit;
|
||||
*lit = operand - 0x21;
|
||||
return lit;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue