mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-11-26 15:53:01 +00:00
(uxn-tnl) Use stack pointer for arithmetic
This commit is contained in:
parent
61896abc7f
commit
1d8babb397
1 changed files with 10 additions and 9 deletions
|
@ -17,31 +17,32 @@ WITH REGARD TO THIS SOFTWARE.
|
||||||
[ L2 ][ N2 ][ T2 ] <
|
[ L2 ][ N2 ][ T2 ] <
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define T s->dat[s->ptr - 1]
|
#define T *sp
|
||||||
#define N s->dat[s->ptr - 2]
|
#define N *(sp-1)
|
||||||
#define L s->dat[s->ptr - 3]
|
#define L *(sp-2)
|
||||||
#define T2 PEEK2(s->dat + s->ptr - 2)
|
#define T2 PEEK2((sp-1))
|
||||||
#define H2 PEEK2(s->dat + s->ptr - 3)
|
#define H2 PEEK2((sp-2))
|
||||||
#define N2 PEEK2(s->dat + s->ptr - 4)
|
#define N2 PEEK2((sp-3))
|
||||||
#define L2 PEEK2(s->dat + s->ptr - 6)
|
#define L2 PEEK2((sp-5))
|
||||||
|
|
||||||
#define HALT(c) { return emu_halt(u, ins, (c), pc - 1); }
|
#define HALT(c) { return emu_halt(u, ins, (c), pc - 1); }
|
||||||
#define FLIP { s = ins & 0x40 ? &u->wst : &u->rst; }
|
#define FLIP { s = ins & 0x40 ? &u->wst : &u->rst; }
|
||||||
#define SET(x, y) { if(x > s->ptr) HALT(1) tmp = (x & k) + y + s->ptr; if(tmp > 254) HALT(2) s->ptr = tmp; }
|
#define SET(x, y) { if(x > s->ptr) HALT(1) tmp = (x & k) + y + s->ptr; if(tmp > 254) HALT(2) s->ptr = tmp; }
|
||||||
#define PUT(o, v) { s->dat[(s->ptr - 1 - (o))] = (v); }
|
#define PUT(o, v) { s->dat[(s->ptr - 1 - (o))] = (v); }
|
||||||
#define PUT2(o, v) { tmp = (v); POKE2(s->dat + (s->ptr - o - 2), tmp); }
|
#define PUT2(o, v) { tmp = (v); POKE2(s->dat + (s->ptr - 2 - (o)), tmp); }
|
||||||
|
|
||||||
int
|
int
|
||||||
uxn_eval(Uxn *u, Uint16 pc)
|
uxn_eval(Uxn *u, Uint16 pc)
|
||||||
{
|
{
|
||||||
int t, n, l, k, tmp, ins, opc;
|
int t, n, l, k, tmp, ins, opc;
|
||||||
Uint8 *ram = u->ram;
|
Uint8 *ram = u->ram, *sp;
|
||||||
Stack *s;
|
Stack *s;
|
||||||
if(!pc || u->dev[0x0f]) return 0;
|
if(!pc || u->dev[0x0f]) return 0;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
ins = ram[pc++];
|
ins = ram[pc++];
|
||||||
k = ins & 0x80 ? 0xff : 0;
|
k = ins & 0x80 ? 0xff : 0;
|
||||||
s = ins & 0x40 ? &u->rst : &u->wst;
|
s = ins & 0x40 ? &u->rst : &u->wst;
|
||||||
|
sp = s->dat + s->ptr - 1;
|
||||||
opc = !(ins & 0x1f) ? (0 - (ins >> 5)) & 0xff : ins & 0x3f;
|
opc = !(ins & 0x1f) ? (0 - (ins >> 5)) & 0xff : ins & 0x3f;
|
||||||
switch(opc) {
|
switch(opc) {
|
||||||
/* IMM */
|
/* IMM */
|
||||||
|
|
Loading…
Reference in a new issue