Make JMI, JCI and JSI relative.
This commit is contained in:
parent
7490666878
commit
f202944566
|
@ -50,9 +50,9 @@ uxn_eval(Uxn *u, Uint16 pc)
|
||||||
switch(opcode - (!opcode * (instr >> 5))) {
|
switch(opcode - (!opcode * (instr >> 5))) {
|
||||||
/* Literals/Calls */
|
/* Literals/Calls */
|
||||||
case -0x0: /* BRK */ return 1;
|
case -0x0: /* BRK */ return 1;
|
||||||
case -0x1: /* JMI */ PEEK16(a, pc) pc = a; break;
|
case -0x1: /* JMI */ PEEK16(a, pc) pc += a + 2; break;
|
||||||
case -0x2: /* JCI */ sp = &u->wst->ptr; src = u->wst; POP8(b) if(b) { PEEK16(a, pc) pc = a; } else pc += 2; break;
|
case -0x2: /* JCI */ sp = &u->wst->ptr; src = u->wst; POP8(b) if(b) { PEEK16(a, pc) pc += a + 2; } else pc += 2; break;
|
||||||
case -0x3: /* JSI */ PUSH16(u->rst, pc + 2) PEEK16(a, pc) pc = a; break;
|
case -0x3: /* JSI */ PUSH16(u->rst, pc + 2) PEEK16(a, pc) pc += a + 2; break;
|
||||||
case -0x4: /* LIT */
|
case -0x4: /* LIT */
|
||||||
case -0x6: /* LITr */ a = u->ram[pc++]; PUSH8(src, a) break;
|
case -0x6: /* LITr */ a = u->ram[pc++]; PUSH8(src, a) break;
|
||||||
case -0x5: /* LIT2 */
|
case -0x5: /* LIT2 */
|
||||||
|
|
12
src/uxnasm.c
12
src/uxnasm.c
|
@ -360,6 +360,7 @@ resolve(void)
|
||||||
{
|
{
|
||||||
Label *l;
|
Label *l;
|
||||||
int i;
|
int i;
|
||||||
|
Uint16 a;
|
||||||
for(i = 0; i < p.rlen; i++) {
|
for(i = 0; i < p.rlen; i++) {
|
||||||
Reference *r = &p.refs[i];
|
Reference *r = &p.refs[i];
|
||||||
switch(r->rune) {
|
switch(r->rune) {
|
||||||
|
@ -382,13 +383,20 @@ resolve(void)
|
||||||
case ':':
|
case ':':
|
||||||
case '=':
|
case '=':
|
||||||
case ';':
|
case ';':
|
||||||
|
if(!(l = findlabel(r->name)))
|
||||||
|
return error("Unknown absolute reference", r->name);
|
||||||
|
p.data[r->addr] = l->addr >> 0x8;
|
||||||
|
p.data[r->addr + 1] = l->addr & 0xff;
|
||||||
|
l->refs++;
|
||||||
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
case '!':
|
case '!':
|
||||||
default:
|
default:
|
||||||
if(!(l = findlabel(r->name)))
|
if(!(l = findlabel(r->name)))
|
||||||
return error("Unknown absolute reference", r->name);
|
return error("Unknown absolute reference", r->name);
|
||||||
p.data[r->addr] = l->addr >> 0x8;
|
a = l->addr - r->addr - 2;
|
||||||
p.data[r->addr + 1] = l->addr & 0xff;
|
p.data[r->addr] = a >> 0x8;
|
||||||
|
p.data[r->addr + 1] = a & 0xff;
|
||||||
l->refs++;
|
l->refs++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue