commit 80b4e4f88d9607348643c97b54ea5d044c1f79ff
parent 6f872feff5254d8aa16d92280c463b76d3c38b61
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date: Sat, 30 Oct 2021 00:28:33 +0100
Use Keep mode for all LIT opcodes
Diffstat:
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/projects/library/asma.tal b/projects/library/asma.tal
@@ -432,12 +432,11 @@ include projects/library/binary-tree.tal
,¬-found JCN
;asma-opcodes/_disasm SUB2 #03 SFT2 ( 00 byte / end* )
+ DUP #00 EQU ,&set-keep JCN ( force keep flag for LIT )
&loop
LDAkr STHr LIT2r 0001 ADD2r ( 00 byte char / end* )
DUP ,¬-end JCN
POP POP2r
- DUP ,¬-zero JCN #80 NIP ( LIT by itself needs keep flag, to distinguish from BRK )
- ¬-zero
SWP
JMP2r
@@ -451,7 +450,7 @@ include projects/library/binary-tree.tal
¬-return
LIT 'k NEQ ,¬-keep JCN
- asma-KEEP-FLAG ORA ,&loop JMP
+ &set-keep asma-KEEP-FLAG ORA ,&loop JMP
¬-keep ( 00 byte / end* )
¬-found ( incoming-ptr* / end* )
diff --git a/src/uxnasm.c b/src/uxnasm.c
@@ -92,6 +92,7 @@ findopcode(char *s)
int m = 0;
if(!scmp(ops[i], s, 3))
continue;
+ if(!i) i |= (1 << 7); /* force keep for LIT */
while(s[3 + m]) {
if(s[3 + m] == '2')
i |= (1 << 5); /* mode: short */
@@ -103,7 +104,6 @@ findopcode(char *s)
return 0; /* failed to match */
m++;
}
- if(!i) i |= (1 << 7); /* force LIT nonzero (keep is ignored) */
return i;
}
return 0;
@@ -112,7 +112,7 @@ findopcode(char *s)
static void
pushbyte(Uint8 b, int lit)
{
- if(lit) pushbyte(findopcode("LITk"), 0);
+ if(lit) pushbyte(findopcode("LIT"), 0);
p.data[p.ptr++] = b;
p.length = p.ptr;
}
@@ -120,7 +120,7 @@ pushbyte(Uint8 b, int lit)
static void
pushshort(Uint16 s, int lit)
{
- if(lit) pushbyte(findopcode("LIT2k"), 0);
+ if(lit) pushbyte(findopcode("LIT2"), 0);
pushbyte((s >> 8) & 0xff, 0);
pushbyte(s & 0xff, 0);
}