Browse code

Use Keep mode for all LIT opcodes

Andrew Alderwick authored on 29/10/2021 23:28:33
Showing 2 changed files
... ...
@@ -432,12 +432,11 @@ include projects/library/binary-tree.tal
432 432
 	,&not-found JCN
433 433
 
434 434
 	;asma-opcodes/_disasm SUB2 #03 SFT2 ( 00 byte / end* )
435
+	DUP #00 EQU ,&set-keep JCN ( force keep flag for LIT )
435 436
 	&loop
436 437
 	LDAkr STHr LIT2r 0001 ADD2r ( 00 byte char / end* )
437 438
 	DUP ,&not-end JCN
438 439
 	POP POP2r
439
-	DUP ,&not-zero JCN #80 NIP ( LIT by itself needs keep flag, to distinguish from BRK )
440
-	&not-zero
441 440
 	SWP
442 441
 	JMP2r
443 442
 
... ...
@@ -451,7 +450,7 @@ include projects/library/binary-tree.tal
451 450
 
452 451
 	&not-return
453 452
 	LIT 'k NEQ ,&not-keep JCN
454
-	asma-KEEP-FLAG ORA ,&loop JMP
453
+	&set-keep asma-KEEP-FLAG ORA ,&loop JMP
455 454
 
456 455
 	&not-keep ( 00 byte / end* )
457 456
 	&not-found ( incoming-ptr* / end* )
... ...
@@ -92,6 +92,7 @@ findopcode(char *s)
92 92
 		int m = 0;
93 93
 		if(!scmp(ops[i], s, 3))
94 94
 			continue;
95
+		if(!i) i |= (1 << 7); /* force keep for LIT */
95 96
 		while(s[3 + m]) {
96 97
 			if(s[3 + m] == '2')
97 98
 				i |= (1 << 5); /* mode: short */
... ...
@@ -103,7 +104,6 @@ findopcode(char *s)
103 104
 				return 0; /* failed to match */
104 105
 			m++;
105 106
 		}
106
-		if(!i) i |= (1 << 7); /* force LIT nonzero (keep is ignored) */
107 107
 		return i;
108 108
 	}
109 109
 	return 0;
... ...
@@ -112,7 +112,7 @@ findopcode(char *s)
112 112
 static void
113 113
 pushbyte(Uint8 b, int lit)
114 114
 {
115
-	if(lit) pushbyte(findopcode("LITk"), 0);
115
+	if(lit) pushbyte(findopcode("LIT"), 0);
116 116
 	p.data[p.ptr++] = b;
117 117
 	p.length = p.ptr;
118 118
 }
... ...
@@ -120,7 +120,7 @@ pushbyte(Uint8 b, int lit)
120 120
 static void
121 121
 pushshort(Uint16 s, int lit)
122 122
 {
123
-	if(lit) pushbyte(findopcode("LIT2k"), 0);
123
+	if(lit) pushbyte(findopcode("LIT2"), 0);
124 124
 	pushbyte((s >> 8) & 0xff, 0);
125 125
 	pushbyte(s & 0xff, 0);
126 126
 }