Use Keep mode for all LIT opcodes

This commit is contained in:
Andrew Alderwick 2021-10-30 00:28:33 +01:00
parent 6f872feff5
commit 80b4e4f88d
2 changed files with 5 additions and 6 deletions

View File

@ -432,12 +432,11 @@ include projects/library/binary-tree.tal
,&not-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 ,&not-end JCN
POP POP2r
DUP ,&not-zero JCN #80 NIP ( LIT by itself needs keep flag, to distinguish from BRK )
&not-zero
SWP
JMP2r
@ -451,7 +450,7 @@ include projects/library/binary-tree.tal
&not-return
LIT 'k NEQ ,&not-keep JCN
asma-KEEP-FLAG ORA ,&loop JMP
&set-keep asma-KEEP-FLAG ORA ,&loop JMP
&not-keep ( 00 byte / end* )
&not-found ( incoming-ptr* / end* )

View File

@ -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);
}