mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-12-18 06:20:18 +00:00
Assembler will now use a single byte when on the zero-page
This commit is contained in:
parent
823e0e8cda
commit
c2a5c8cac2
1 changed files with 19 additions and 9 deletions
|
@ -263,11 +263,11 @@ walktoken(char *w)
|
||||||
if(findopcode(w) || scmp(w, "BRK", 4))
|
if(findopcode(w) || scmp(w, "BRK", 4))
|
||||||
return 1;
|
return 1;
|
||||||
switch(w[0]) {
|
switch(w[0]) {
|
||||||
case '=': return 4; /* STR helper (lit addr-hb addr-lb str) */
|
case '=': return 4 - (findlabeladdr(w + 1) < 0x0100); /* POK/STR helper (lit addr(1/2) str) */
|
||||||
case '~': return 4; /* LDR helper (lit addr-hb addr-lb ldr) */
|
case '~': return 4 - (findlabeladdr(w + 1) < 0x0100); /* PEK/LDR helper (lit addr(1/2) ldr) */
|
||||||
case ',': return 3; /* lit2 addr-hb addr-lb */
|
case ',': return 3; /* lit2 addr-hb addr-lb */
|
||||||
case '.': return 2; /* addr-hb addr-lb */
|
case '.': return 2; /* addr-hb addr-lb */
|
||||||
case '^': return 2; /* Relative jump: lit addr-offset */
|
case '^': return 2; /* Relative jump: lit addr-offset */
|
||||||
case '#': return (slen(w + 1) == 2 ? 2 : 3);
|
case '#': return (slen(w + 1) == 2 ? 2 : 3);
|
||||||
}
|
}
|
||||||
if((m = findmacro(w))) {
|
if((m = findmacro(w))) {
|
||||||
|
@ -298,15 +298,25 @@ parsetoken(char *w)
|
||||||
} else if(w[0] == '=' && (l = findlabel(w + 1))) {
|
} else if(w[0] == '=' && (l = findlabel(w + 1))) {
|
||||||
if(!findlabellen(w + 1) || findlabellen(w + 1) > 2)
|
if(!findlabellen(w + 1) || findlabellen(w + 1) > 2)
|
||||||
return error("Invalid store helper", w);
|
return error("Invalid store helper", w);
|
||||||
pushshort(findlabeladdr(w + 1), 1);
|
if(findlabeladdr(w + 1) < 0x0100) {
|
||||||
pushbyte(findopcode(findlabellen(w + 1) == 2 ? "STR2" : "POK2"), 0);
|
pushbyte(findlabeladdr(w + 1), 1);
|
||||||
|
pushbyte(findopcode(findlabellen(w + 1) == 2 ? "STR" : "POK"), 0);
|
||||||
|
} else {
|
||||||
|
pushshort(findlabeladdr(w + 1), 1);
|
||||||
|
pushbyte(findopcode(findlabellen(w + 1) == 2 ? "STR2" : "POK2"), 0);
|
||||||
|
}
|
||||||
l->refs++;
|
l->refs++;
|
||||||
return 1;
|
return 1;
|
||||||
} else if(w[0] == '~' && (l = findlabel(w + 1))) {
|
} else if(w[0] == '~' && (l = findlabel(w + 1))) {
|
||||||
if(!findlabellen(w + 1) || findlabellen(w + 1) > 2)
|
if(!findlabellen(w + 1) || findlabellen(w + 1) > 2)
|
||||||
return error("Invalid load helper", w);
|
return error("Invalid load helper", w);
|
||||||
pushshort(findlabeladdr(w + 1), 1);
|
if(findlabeladdr(w + 1) < 0x0100) {
|
||||||
pushbyte(findopcode(findlabellen(w + 1) == 2 ? "LDR2" : "PEK2"), 0);
|
pushbyte(findlabeladdr(w + 1), 1);
|
||||||
|
pushbyte(findopcode(findlabellen(w + 1) == 2 ? "LDR" : "PEK"), 0);
|
||||||
|
} else {
|
||||||
|
pushshort(findlabeladdr(w + 1), 1);
|
||||||
|
pushbyte(findopcode(findlabellen(w + 1) == 2 ? "LDR2" : "PEK2"), 0);
|
||||||
|
}
|
||||||
l->refs++;
|
l->refs++;
|
||||||
return 1;
|
return 1;
|
||||||
} else if((op = findopcode(w)) || scmp(w, "BRK", 4)) {
|
} else if((op = findopcode(w)) || scmp(w, "BRK", 4)) {
|
||||||
|
|
Loading…
Reference in a new issue