Rename ERROR/err to FAULT/fault
This commit is contained in:
parent
2a825de2fd
commit
c296187ea9
14
src/uxn.c
14
src/uxn.c
|
@ -17,12 +17,12 @@ WITH REGARD TO THIS SOFTWARE.
|
||||||
pc: program counter. sp: ptr to src stack ptr. kptr: "keep" mode copy of src stack ptr.
|
pc: program counter. sp: ptr to src stack ptr. kptr: "keep" mode copy of src stack ptr.
|
||||||
x,y: macro in params. d: macro in device. j,k,dev: macro temp variables. o: macro out param. */
|
x,y: macro in params. d: macro in device. j,k,dev: macro temp variables. o: macro out param. */
|
||||||
|
|
||||||
#define ERROR(s, n) { errcode = n * 2 + (s == &u->rst); goto err; }
|
#define FAULT(s, n) { errcode = n * 2 + (s == &u->rst); goto fault; }
|
||||||
#define PUSH8(s, x) { if(s->ptr == 0xff) { ERROR(s, 2) } s->dat[s->ptr++] = (x); }
|
#define PUSH8(s, x) { if(s->ptr == 0xff) { FAULT(s, 2) } s->dat[s->ptr++] = (x); }
|
||||||
#define PUSH16(s, x) { if((j = s->ptr) >= 0xfe) { ERROR(s, 2) } k = (x); s->dat[j] = k >> 8; s->dat[j + 1] = k; s->ptr = j + 2; }
|
#define PUSH16(s, x) { if((j = s->ptr) >= 0xfe) { FAULT(s, 2) } k = (x); s->dat[j] = k >> 8; s->dat[j + 1] = k; s->ptr = j + 2; }
|
||||||
#define PUSH(s, x) { if(bs) { PUSH16(s, (x)) } else { PUSH8(s, (x)) } }
|
#define PUSH(s, x) { if(bs) { PUSH16(s, (x)) } else { PUSH8(s, (x)) } }
|
||||||
#define POP8(o) { if(!(j = *sp)) { ERROR(src, 1) } o = (Uint16)src->dat[--j]; *sp = j; }
|
#define POP8(o) { if(!(j = *sp)) { FAULT(src, 1) } o = (Uint16)src->dat[--j]; *sp = j; }
|
||||||
#define POP16(o) { if((j = *sp) <= 1) { ERROR(src, 1) } o = src->dat[j - 1]; o += src->dat[j - 2] << 8; *sp = j - 2; }
|
#define POP16(o) { if((j = *sp) <= 1) { FAULT(src, 1) } o = src->dat[j - 1]; o += src->dat[j - 2] << 8; *sp = j - 2; }
|
||||||
#define POP(o) { if(bs) { POP16(o) } else { POP8(o) } }
|
#define POP(o) { if(bs) { POP16(o) } else { POP8(o) } }
|
||||||
#define POKE(x, y) { if(bs) { u->ram[(x)] = (y) >> 8; u->ram[(x) + 1] = (y); } else { u->ram[(x)] = y; } }
|
#define POKE(x, y) { if(bs) { u->ram[(x)] = (y) >> 8; u->ram[(x) + 1] = (y); } else { u->ram[(x)] = y; } }
|
||||||
#define PEEK16(o, x) { o = (u->ram[(x)] << 8) + u->ram[(x) + 1]; }
|
#define PEEK16(o, x) { o = (u->ram[(x)] << 8) + u->ram[(x) + 1]; }
|
||||||
|
@ -90,7 +90,7 @@ uxn_eval(Uxn *u, Uint16 pc)
|
||||||
case 0x18: /* ADD */ POP(a) POP(b) PUSH(src, b + a) break;
|
case 0x18: /* ADD */ POP(a) POP(b) PUSH(src, b + a) break;
|
||||||
case 0x19: /* SUB */ POP(a) POP(b) PUSH(src, b - a) break;
|
case 0x19: /* SUB */ POP(a) POP(b) PUSH(src, b - a) break;
|
||||||
case 0x1a: /* MUL */ POP(a) POP(b) PUSH(src, (Uint32)b * a) break;
|
case 0x1a: /* MUL */ POP(a) POP(b) PUSH(src, (Uint32)b * a) break;
|
||||||
case 0x1b: /* DIV */ POP(a) POP(b) if(a == 0) { ERROR(src, 3) } PUSH(src, b / a) break;
|
case 0x1b: /* DIV */ POP(a) POP(b) if(a == 0) { FAULT(src, 3) } PUSH(src, b / a) break;
|
||||||
case 0x1c: /* AND */ POP(a) POP(b) PUSH(src, b & a) break;
|
case 0x1c: /* AND */ POP(a) POP(b) PUSH(src, b & a) break;
|
||||||
case 0x1d: /* ORA */ POP(a) POP(b) PUSH(src, b | a) break;
|
case 0x1d: /* ORA */ POP(a) POP(b) PUSH(src, b | a) break;
|
||||||
case 0x1e: /* EOR */ POP(a) POP(b) PUSH(src, b ^ a) break;
|
case 0x1e: /* EOR */ POP(a) POP(b) PUSH(src, b ^ a) break;
|
||||||
|
@ -99,7 +99,7 @@ uxn_eval(Uxn *u, Uint16 pc)
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
err:
|
fault:
|
||||||
return uxn_halt(u, errcode >> 1, (errcode & 1) == 0 ? "Working-stack" : "Return-stack", pc - 1);
|
return uxn_halt(u, errcode >> 1, (errcode & 1) == 0 ? "Working-stack" : "Return-stack", pc - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue