Browse code

Implemented keep opcode flag

Andrew Alderwick authored on 12/05/2021 17:42:24
Showing 3 changed files
... ...
@@ -108,7 +108,7 @@ BRK
108 108
 		OVR #10 SWP - .Audio0/output DEI #04 SFT < .Screen/color DEO
109 109
 		.Screen/y DEI2 #0002 ++ .Screen/y DEO2
110 110
 		( incr ) SWP #01 + SWP
111
-		DUP2 < ,&loop JCN
111
+		LTHk ,&loop JCN
112 112
 	POP2
113 113
 
114 114
 BRK
... ...
@@ -310,7 +310,7 @@ RTN
310 310
 	DUP2 #0018 ++
311 311
 	&loop
312 312
 		( move ) OVR2 .Screen/y DEO2
313
-		( draw ) DUPr STHr .Screen/color DEO
313
+		( draw ) STHrk .Screen/color DEO
314 314
 		( incr ) .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2  
315 315
 		( incr ) SWP2 #0008 ++ SWP2
316 316
 		OVR2 OVR2 << ,&loop JCN
... ...
@@ -371,7 +371,7 @@ RTN
371 371
 		.Screen/x DEI2 #0001 ++ .Screen/x DEO2
372 372
 		( draw ) OVR .Audio0/length DEI2 SWP POP > #02 * #01 + .Screen/color DEO
373 373
 		( incr ) SWP #01 + SWP
374
-		DUP2 < ,&loop JCN
374
+		LTHk ,&loop JCN
375 375
 	POP2
376 376
 
377 377
 	( range )
... ...
@@ -390,7 +390,7 @@ RTN
390 390
 	.wave-view/y1 LDZ2 DUP2 #0020 ++
391 391
 	&loop
392 392
 		OVR2 .Screen/y DEO2
393
-		( draw ) DUPr STHr .Screen/color DEO
393
+		( draw ) STHrk .Screen/color DEO
394 394
 		( incr ) SWP2 #0001 ++ SWP2
395 395
 		OVR2 OVR2 << ,&loop JCN
396 396
 	POP2 POP2
... ...
@@ -414,9 +414,9 @@ RTN
414 414
 	( draw ) #21 .Screen/color DEO
415 415
 	.Screen/x DEI2 #0004 ++ .Screen/x DEO2
416 416
 	.Screen/y DEI2 #0008 ++ .Screen/y DEO2
417
-	;font-hex #00 DUPr STHr #08 * ++ .Screen/addr DEO2
417
+	;font-hex #00 STHrk #08 * ++ .Screen/addr DEO2
418 418
 	( draw ) #21 .Screen/color DEO
419
-	.Screen/x DEI2 #0004 -- #00 #00 DUPr STHr ;knob-offsetx ++ LDA ++ .Screen/x DEO2
419
+	.Screen/x DEI2 #0004 -- #00 #00 STHrk ;knob-offsetx ++ LDA ++ .Screen/x DEO2
420 420
 	.Screen/y DEI2 #0010 -- #00 #00 STHr ;knob-offsety ++ LDA ++ .Screen/y DEO2
421 421
 	;knob-icns #0020 ++ .Screen/addr DEO2
422 422
 	( draw ) #25 .Screen/color DEO
... ...
@@ -427,13 +427,13 @@ RTN
427 427
 
428 428
 	STH SWP 
429 429
 	DUP #04 SFT TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
430
-	( draw ) DUPr STHr .Screen/color DEO
430
+	( draw ) STHrk .Screen/color DEO
431 431
 	#0f AND TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
432 432
 	.Screen/x DEI2 #0008 ++ .Screen/x DEO2
433
-	( draw ) DUPr STHr .Screen/color DEO
433
+	( draw ) STHrk .Screen/color DEO
434 434
 	DUP #04 SFT TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
435 435
 	.Screen/x DEI2 #0008 ++ .Screen/x DEO2
436
-	( draw ) DUPr STHr .Screen/color DEO
436
+	( draw ) STHrk .Screen/color DEO
437 437
 	#0f AND TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
438 438
 	.Screen/x DEI2 #0008 ++ .Screen/x DEO2
439 439
 	( draw ) STHr .Screen/color DEO
... ...
@@ -119,6 +119,8 @@ findopcode(char *s)
119 119
 				i |= (1 << 5); /* mode: short */
120 120
 			else if(s[3 + m] == 'r')
121 121
 				i |= (1 << 6); /* mode: return */
122
+			else if(s[3 + m] == 'k')
123
+				i |= (1 << 7); /* mode: keep */
122 124
 			else
123 125
 				return 0; /* failed to match */
124 126
 			m++;
... ...
@@ -17,15 +17,15 @@ WITH REGARD TO THIS SOFTWARE.
17 17
 
18 18
 /* clang-format off */
19 19
 void   push8(Stack *s, Uint8 a) { if (s->ptr == 0xff) { s->error = 2; return; } s->dat[s->ptr++] = a; }
20
-Uint8  pop8(Stack *s) { if (s->ptr == 0) { s->error = 1; return 0; } return s->dat[--s->ptr]; }
21
-Uint8  peek8(Stack *s, Uint8 a) { if (s->ptr < a + 1) s->error = 1; return s->dat[s->ptr - a - 1]; }
20
+Uint8  pop8_keep(Stack *s, Uint8 a) { if (s->ptr < a + 1) s->error = 1; return s->dat[s->ptr - a - 1]; }
21
+Uint8  pop8_nokeep(Stack *s, Uint8 a) { if (s->ptr == 0) { s->error = 1; return 0; } return s->dat[--s->ptr]; (void) a; }
22
+static Uint8 (*pop8)(Stack *s, Uint8 a);
22 23
 void   mempoke8(Uint8 *m, Uint16 a, Uint8 b) { m[a] = b; }
23 24
 Uint8  mempeek8(Uint8 *m, Uint16 a) { return m[a]; }
24 25
 void   devpoke8(Device *d, Uint8 a, Uint8 b) { d->dat[a & 0xf] = b; d->talk(d, a & 0x0f, 1); }
25 26
 Uint8  devpeek8(Device *d, Uint8 a) { d->talk(d, a & 0x0f, 0); return d->dat[a & 0xf];  }
26 27
 void   push16(Stack *s, Uint16 a) { push8(s, a >> 8); push8(s, a); }
27
-Uint16 pop16(Stack *s) { return pop8(s) + (pop8(s) << 8); }
28
-Uint16 peek16(Stack *s, Uint8 a) { return peek8(s, a * 2) + (peek8(s, a * 2 + 1) << 8); }
28
+Uint16 pop16(Stack *s, Uint8 a) { return pop8(s, a * 2) + (pop8(s, a * 2 + 1) << 8); }
29 29
 void   mempoke16(Uint8 *m, Uint16 a, Uint16 b) { mempoke8(m, a, b >> 8); mempoke8(m, a + 1, b); }
30 30
 Uint16 mempeek16(Uint8 *m, Uint16 a) { return (mempeek8(m, a) << 8) + mempeek8(m, a + 1); }
31 31
 void   devpoke16(Device *d, Uint8 a, Uint16 b) { devpoke8(d, a, b >> 8); devpoke8(d, a + 1, b); }
... ...
@@ -34,72 +34,72 @@ Uint16 devpeek16(Device *d, Uint16 a) { return (devpeek8(d, a) << 8) + devpeek8(
34 34
 void op_brk(Uxn *u) { u->ram.ptr = 0; }
35 35
 void op_nop(Uxn *u) { (void)u; }
36 36
 void op_lit(Uxn *u) { push8(u->src, mempeek8(u->ram.dat, u->ram.ptr++)); }
37
-void op_pop(Uxn *u) { pop8(u->src); }
38
-void op_dup(Uxn *u) { push8(u->src, peek8(u->src, 0)); }
39
-void op_swp(Uxn *u) { Uint8 b = pop8(u->src), a = pop8(u->src); push8(u->src, b); push8(u->src, a); }
40
-void op_ovr(Uxn *u) { push8(u->src, peek8(u->src, 1)); }
41
-void op_rot(Uxn *u) { Uint8 c = pop8(u->src), b = pop8(u->src), a = pop8(u->src); push8(u->src, b); push8(u->src, c); push8(u->src, a); }
37
+void op_pop(Uxn *u) { pop8(u->src, 0); }
38
+void op_dup(Uxn *u) { Uint8 a = pop8(u->src, 0); push8(u->src, a); push8(u->src, a); }
39
+void op_swp(Uxn *u) { Uint8 b = pop8(u->src, 0), a = pop8(u->src, 1); push8(u->src, b); push8(u->src, a); }
40
+void op_ovr(Uxn *u) { Uint8 a = pop8(u->src, 0), b = pop8(u->src, 1); push8(u->src, b); push8(u->src, a); push8(u->src, b); }
41
+void op_rot(Uxn *u) { Uint8 c = pop8(u->src, 0), b = pop8(u->src, 1), a = pop8(u->src, 2); push8(u->src, b); push8(u->src, c); push8(u->src, a); }
42 42
 /* Logic */
43
-void op_equ(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b == a); }
44
-void op_neq(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b != a); }
45
-void op_gth(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b > a); }
46
-void op_lth(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b < a); }
47
-void op_jmp(Uxn *u) { Uint8 a = pop8(u->src); u->ram.ptr += (Sint8)a; }
48
-void op_jnz(Uxn *u) { Uint8 a = pop8(u->src); if (pop8(u->src)) u->ram.ptr += (Sint8)a; }
49
-void op_jsr(Uxn *u) { Uint8 a = pop8(u->src); push16(u->dst, u->ram.ptr); u->ram.ptr += (Sint8)a; }
50
-void op_sth(Uxn *u) { Uint8 a = pop8(u->src); push8(u->dst, a); }
43
+void op_equ(Uxn *u) { Uint8 a = pop8(u->src, 0), b = pop8(u->src, 1); push8(u->src, b == a); }
44
+void op_neq(Uxn *u) { Uint8 a = pop8(u->src, 0), b = pop8(u->src, 1); push8(u->src, b != a); }
45
+void op_gth(Uxn *u) { Uint8 a = pop8(u->src, 0), b = pop8(u->src, 1); push8(u->src, b > a); }
46
+void op_lth(Uxn *u) { Uint8 a = pop8(u->src, 0), b = pop8(u->src, 1); push8(u->src, b < a); }
47
+void op_jmp(Uxn *u) { Uint8 a = pop8(u->src, 0); u->ram.ptr += (Sint8)a; }
48
+void op_jnz(Uxn *u) { Uint8 a = pop8(u->src, 0); if (pop8(u->src, 1)) u->ram.ptr += (Sint8)a; }
49
+void op_jsr(Uxn *u) { Uint8 a = pop8(u->src, 0); push16(u->dst, u->ram.ptr); u->ram.ptr += (Sint8)a; }
50
+void op_sth(Uxn *u) { Uint8 a = pop8(u->src, 0); push8(u->dst, a); }
51 51
 /* Memory */
52
-void op_pek(Uxn *u) { Uint8 a = pop8(u->src); push8(u->src, mempeek8(u->ram.dat, a)); }
53
-void op_pok(Uxn *u) { Uint8 a = pop8(u->src); Uint8 b = pop8(u->src); mempoke8(u->ram.dat, a, b); }
54
-void op_ldr(Uxn *u) { Uint8 a = pop8(u->src); push8(u->src, mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a)); }
55
-void op_str(Uxn *u) { Uint8 a = pop8(u->src); Uint8 b = pop8(u->src); mempoke8(u->ram.dat, u->ram.ptr + (Sint8)a, b); }
56
-void op_lda(Uxn *u) { Uint16 a = pop16(u->src); push8(u->src, mempeek8(u->ram.dat, a)); }
57
-void op_sta(Uxn *u) { Uint16 a = pop16(u->src); Uint8 b = pop8(u->src); mempoke8(u->ram.dat, a, b); }
58
-void op_dei(Uxn *u) { Uint8 a = pop8(u->src); push8(u->src, devpeek8(&u->dev[a >> 4], a)); }
59
-void op_deo(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); devpoke8(&u->dev[a >> 4], a, b); }
52
+void op_pek(Uxn *u) { Uint8 a = pop8(u->src, 0); push8(u->src, mempeek8(u->ram.dat, a)); }
53
+void op_pok(Uxn *u) { Uint8 a = pop8(u->src, 0); Uint8 b = pop8(u->src, 1); mempoke8(u->ram.dat, a, b); }
54
+void op_ldr(Uxn *u) { Uint8 a = pop8(u->src, 0); push8(u->src, mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a)); }
55
+void op_str(Uxn *u) { Uint8 a = pop8(u->src, 0); Uint8 b = pop8(u->src, 1); mempoke8(u->ram.dat, u->ram.ptr + (Sint8)a, b); }
56
+void op_lda(Uxn *u) { Uint16 a = pop16(u->src, 0); push8(u->src, mempeek8(u->ram.dat, a)); }
57
+void op_sta(Uxn *u) { Uint16 a = pop16(u->src, 0); Uint8 b = pop8(u->src, 0); mempoke8(u->ram.dat, a, b); }
58
+void op_dei(Uxn *u) { Uint8 a = pop8(u->src, 0); push8(u->src, devpeek8(&u->dev[a >> 4], a)); }
59
+void op_deo(Uxn *u) { Uint8 a = pop8(u->src, 0), b = pop8(u->src, 1); devpoke8(&u->dev[a >> 4], a, b); }
60 60
 /* Arithmetic */
61
-void op_add(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b + a); }
62
-void op_sub(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b - a); }
63
-void op_mul(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b * a); }
64
-void op_div(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b / a); }
65
-void op_and(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b & a); }
66
-void op_ora(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b | a); }
67
-void op_eor(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b ^ a); }
68
-void op_sft(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b >> (a & 0x07) << ((a & 0x70) >> 4)); }
61
+void op_add(Uxn *u) { Uint8 a = pop8(u->src, 0), b = pop8(u->src, 1); push8(u->src, b + a); }
62
+void op_sub(Uxn *u) { Uint8 a = pop8(u->src, 0), b = pop8(u->src, 1); push8(u->src, b - a); }
63
+void op_mul(Uxn *u) { Uint8 a = pop8(u->src, 0), b = pop8(u->src, 1); push8(u->src, b * a); }
64
+void op_div(Uxn *u) { Uint8 a = pop8(u->src, 0), b = pop8(u->src, 1); push8(u->src, b / a); }
65
+void op_and(Uxn *u) { Uint8 a = pop8(u->src, 0), b = pop8(u->src, 1); push8(u->src, b & a); }
66
+void op_ora(Uxn *u) { Uint8 a = pop8(u->src, 0), b = pop8(u->src, 1); push8(u->src, b | a); }
67
+void op_eor(Uxn *u) { Uint8 a = pop8(u->src, 0), b = pop8(u->src, 1); push8(u->src, b ^ a); }
68
+void op_sft(Uxn *u) { Uint8 a = pop8(u->src, 0), b = pop8(u->src, 1); push8(u->src, b >> (a & 0x07) << ((a & 0x70) >> 4)); }
69 69
 /* Stack */
70 70
 void op_lit16(Uxn *u) { push16(u->src, mempeek16(u->ram.dat, u->ram.ptr++)); u->ram.ptr++; }
71
-void op_pop16(Uxn *u) { pop16(u->src); }
72
-void op_dup16(Uxn *u) { push16(u->src, peek16(u->src, 0)); }
73
-void op_swp16(Uxn *u) { Uint16 b = pop16(u->src), a = pop16(u->src); push16(u->src, b); push16(u->src, a); }
74
-void op_ovr16(Uxn *u) { push16(u->src, peek16(u->src, 1)); }
75
-void op_rot16(Uxn *u) { Uint16 c = pop16(u->src), b = pop16(u->src), a = pop16(u->src); push16(u->src, b); push16(u->src, c); push16(u->src, a); }
71
+void op_pop16(Uxn *u) { pop16(u->src, 0); }
72
+void op_dup16(Uxn *u) { Uint16 a = pop16(u->src, 0); push16(u->src, a); push16(u->src, a); }
73
+void op_swp16(Uxn *u) { Uint16 b = pop16(u->src, 0), a = pop16(u->src, 1); push16(u->src, b); push16(u->src, a); }
74
+void op_ovr16(Uxn *u) { Uint16 a = pop16(u->src, 0), b = pop16(u->src, 1); push16(u->src, b); push16(u->src, a); push16(u->src, b); }
75
+void op_rot16(Uxn *u) { Uint16 c = pop16(u->src, 0), b = pop16(u->src, 1), a = pop16(u->src, 2); push16(u->src, b); push16(u->src, c); push16(u->src, a); }
76 76
 /* Logic(16-bits) */
77
-void op_equ16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push8(u->src, b == a); }
78
-void op_neq16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push8(u->src, b != a); }
79
-void op_gth16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push8(u->src, b > a); }
80
-void op_lth16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push8(u->src, b < a); }
81
-void op_jmp16(Uxn *u) { u->ram.ptr = pop16(u->src); }
82
-void op_jnz16(Uxn *u) { Uint16 a = pop16(u->src); if (pop8(u->src)) u->ram.ptr = a; }
83
-void op_jsr16(Uxn *u) { push16(u->dst, u->ram.ptr); u->ram.ptr = pop16(u->src); }
84
-void op_sth16(Uxn *u) { Uint16 a = pop16(u->src); push16(u->dst, a); }
77
+void op_equ16(Uxn *u) { Uint16 a = pop16(u->src, 0), b = pop16(u->src, 1); push8(u->src, b == a); }
78
+void op_neq16(Uxn *u) { Uint16 a = pop16(u->src, 0), b = pop16(u->src, 1); push8(u->src, b != a); }
79
+void op_gth16(Uxn *u) { Uint16 a = pop16(u->src, 0), b = pop16(u->src, 1); push8(u->src, b > a); }
80
+void op_lth16(Uxn *u) { Uint16 a = pop16(u->src, 0), b = pop16(u->src, 1); push8(u->src, b < a); }
81
+void op_jmp16(Uxn *u) { u->ram.ptr = pop16(u->src, 0); }
82
+void op_jnz16(Uxn *u) { Uint16 a = pop16(u->src, 0); if (pop8(u->src, 0)) u->ram.ptr = a; }
83
+void op_jsr16(Uxn *u) { push16(u->dst, u->ram.ptr); u->ram.ptr = pop16(u->src, 0); }
84
+void op_sth16(Uxn *u) { Uint16 a = pop16(u->src, 0); push16(u->dst, a); }
85 85
 /* Memory(16-bits) */
86
-void op_pek16(Uxn *u) { Uint8 a = pop8(u->src); push16(u->src, mempeek16(u->ram.dat, a)); }
87
-void op_pok16(Uxn *u) { Uint8 a = pop8(u->src); Uint16 b = pop16(u->src); mempoke16(u->ram.dat, a, b); }
88
-void op_ldr16(Uxn *u) { Uint8 a = pop8(u->src); push16(u->src, mempeek16(u->ram.dat, u->ram.ptr + (Sint8)a)); }
89
-void op_str16(Uxn *u) { Uint8 a = pop8(u->src); Uint16 b = pop16(u->src); mempoke16(u->ram.dat, u->ram.ptr + (Sint8)a, b); }
90
-void op_lda16(Uxn *u) { Uint16 a = pop16(u->src); push16(u->src, mempeek16(u->ram.dat, a)); }
91
-void op_sta16(Uxn *u) { Uint16 a = pop16(u->src); Uint16 b = pop16(u->src); mempoke16(u->ram.dat, a, b); }
92
-void op_dei16(Uxn *u) { Uint8 a = pop8(u->src); push16(u->src, devpeek16(&u->dev[a >> 4], a)); }
93
-void op_deo16(Uxn *u) { Uint8 a = pop8(u->src); Uint16 b = pop16(u->src); devpoke16(&u->dev[a >> 4], a, b); }
86
+void op_pek16(Uxn *u) { Uint8 a = pop8(u->src, 0); push16(u->src, mempeek16(u->ram.dat, a)); }
87
+void op_pok16(Uxn *u) { Uint8 a = pop8(u->src, 0); Uint16 b = pop16(u->src, 0); mempoke16(u->ram.dat, a, b); }
88
+void op_ldr16(Uxn *u) { Uint8 a = pop8(u->src, 0); push16(u->src, mempeek16(u->ram.dat, u->ram.ptr + (Sint8)a)); }
89
+void op_str16(Uxn *u) { Uint8 a = pop8(u->src, 0); Uint16 b = pop16(u->src, 0); mempoke16(u->ram.dat, u->ram.ptr + (Sint8)a, b); }
90
+void op_lda16(Uxn *u) { Uint16 a = pop16(u->src, 0); push16(u->src, mempeek16(u->ram.dat, a)); }
91
+void op_sta16(Uxn *u) { Uint16 a = pop16(u->src, 0); Uint16 b = pop16(u->src, 1); mempoke16(u->ram.dat, a, b); }
92
+void op_dei16(Uxn *u) { Uint8 a = pop8(u->src, 0); push16(u->src, devpeek16(&u->dev[a >> 4], a)); }
93
+void op_deo16(Uxn *u) { Uint8 a = pop8(u->src, 0); Uint16 b = pop16(u->src, 0); devpoke16(&u->dev[a >> 4], a, b); }
94 94
 /* Arithmetic(16-bits) */
95
-void op_add16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b + a); }
96
-void op_sub16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b - a); }
97
-void op_mul16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b * a); }
98
-void op_div16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b / a); }
99
-void op_and16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b & a); }
100
-void op_ora16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b | a); }
101
-void op_eor16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b ^ a); }
102
-void op_sft16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b >> (a & 0x0007) << ((a & 0x0070) >> 4)); }
95
+void op_add16(Uxn *u) { Uint16 a = pop16(u->src, 0), b = pop16(u->src, 1); push16(u->src, b + a); }
96
+void op_sub16(Uxn *u) { Uint16 a = pop16(u->src, 0), b = pop16(u->src, 1); push16(u->src, b - a); }
97
+void op_mul16(Uxn *u) { Uint16 a = pop16(u->src, 0), b = pop16(u->src, 1); push16(u->src, b * a); }
98
+void op_div16(Uxn *u) { Uint16 a = pop16(u->src, 0), b = pop16(u->src, 1); push16(u->src, b / a); }
99
+void op_and16(Uxn *u) { Uint16 a = pop16(u->src, 0), b = pop16(u->src, 1); push16(u->src, b & a); }
100
+void op_ora16(Uxn *u) { Uint16 a = pop16(u->src, 0), b = pop16(u->src, 1); push16(u->src, b | a); }
101
+void op_eor16(Uxn *u) { Uint16 a = pop16(u->src, 0), b = pop16(u->src, 1); push16(u->src, b ^ a); }
102
+void op_sft16(Uxn *u) { Uint16 a = pop16(u->src, 0), b = pop16(u->src, 1); push16(u->src, b >> (a & 0x0007) << ((a & 0x0070) >> 4)); }
103 103
 
104 104
 void (*ops[])(Uxn *u) = {
105 105
 	op_brk, op_lit, op_nop, op_pop, op_dup, op_swp, op_ovr, op_rot,
... ...
@@ -128,9 +128,10 @@ haltuxn(Uxn *u, char *name, int id)
128 128
 void
129 129
 opcuxn(Uxn *u, Uint8 instr)
130 130
 {
131
-	Uint8 op = instr & 0x3f, freturn = instr & 0x40;
131
+	Uint8 op = instr & 0x3f, freturn = instr & 0x40, fkeep = instr & 0x80;
132 132
 	u->src = freturn ? &u->rst : &u->wst;
133 133
 	u->dst = freturn ? &u->wst : &u->rst;
134
+	pop8 = fkeep ? pop8_keep : pop8_nokeep;
134 135
 	(*ops[op])(u);
135 136
 }
136 137