Use ephemeral variable for literal operands

This commit is contained in:
Maurizio Porrato 2020-01-22 08:37:17 +00:00
parent 9ceac9ae5a
commit bc55eadb82
1 changed files with 4 additions and 8 deletions

12
dsim.c
View File

@ -14,6 +14,8 @@
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 */
bool skip_next;
uint64_t ticks;
bool running;
@ -109,13 +111,6 @@ struct dev_entry iodevs[] = {
{ 0x6d53647c, 0x62e037d3, 0x00000000, debug_irqh, NULL, NULL, NULL }, /* Debug device */
};
uint16_t lit[] = {
0xffff, 0, 1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30
};
uint16_t *val(int operand, bool is_a)
{
switch (operand) {
@ -195,7 +190,8 @@ uint16_t *val(int operand, bool is_a)
ticks++;
return &ram[rpc++]; /* FIXME: write to literal */
default:
return &lit[operand-0x20];
lit = operand - 0x21;
return &lit;
}
}