0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-12-18 22:42:08 +00:00

Assembler will now use a single byte when on the zero-page

This commit is contained in:
neauoire 2021-03-28 09:48:00 -07:00
parent 823e0e8cda
commit c2a5c8cac2

View file

@ -263,8 +263,8 @@ 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 */
@ -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);
if(findlabeladdr(w + 1) < 0x0100) {
pushbyte(findlabeladdr(w + 1), 1);
pushbyte(findopcode(findlabellen(w + 1) == 2 ? "STR" : "POK"), 0);
} else {
pushshort(findlabeladdr(w + 1), 1); pushshort(findlabeladdr(w + 1), 1);
pushbyte(findopcode(findlabellen(w + 1) == 2 ? "STR2" : "POK2"), 0); 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);
if(findlabeladdr(w + 1) < 0x0100) {
pushbyte(findlabeladdr(w + 1), 1);
pushbyte(findopcode(findlabellen(w + 1) == 2 ? "LDR" : "PEK"), 0);
} else {
pushshort(findlabeladdr(w + 1), 1); pushshort(findlabeladdr(w + 1), 1);
pushbyte(findopcode(findlabellen(w + 1) == 2 ? "LDR2" : "PEK2"), 0); 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)) {