mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-12-03 11:07:25 +00:00
(uxnasm) Fix valid macro names being rejected.
Macro names that begin with the name of an opcode were being rejected incorrectly. “STA” would not be a valid macro name since it is an opcode, but “STACK” should be fine.
This commit is contained in:
parent
d49981c4ce
commit
c2ffe63cc3
1 changed files with 13 additions and 16 deletions
29
src/uxnasm.c
29
src/uxnasm.c
|
@ -99,30 +99,27 @@ findlabel(char *name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static Uint8
|
||||
findmode(char *s)
|
||||
{
|
||||
int i = 0;
|
||||
while(s[0]) {
|
||||
switch(s[0]) {
|
||||
case '2': i |= (1 << 5); break; /* mode: short */
|
||||
case 'r': i |= (1 << 6); break; /* mode: return */
|
||||
case 'k': i |= (1 << 7); break; /* mode: keep */
|
||||
}
|
||||
s++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
static Uint8
|
||||
findopcode(char *s)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 0x20; i++) {
|
||||
int m = 0;
|
||||
if(!scmp(ops[i], s, 3))
|
||||
continue;
|
||||
if(!i) i |= (1 << 7); /* force keep for LIT */
|
||||
return i |= findmode(s + 3);
|
||||
while(s[3 + m]) {
|
||||
if(s[3 + m] == '2')
|
||||
i |= (1 << 5); /* mode: short */
|
||||
else if(s[3 + m] == 'r')
|
||||
i |= (1 << 6); /* mode: return */
|
||||
else if(s[3 + m] == 'k')
|
||||
i |= (1 << 7); /* mode: keep */
|
||||
else
|
||||
return 0; /* failed to match */
|
||||
m++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue