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
1 changed files with 19 additions and 9 deletions

View File

@ -263,11 +263,11 @@ walktoken(char *w)
if(findopcode(w) || scmp(w, "BRK", 4))
return 1;
switch(w[0]) {
case '=': return 4; /* STR helper (lit addr-hb addr-lb str) */
case '~': return 4; /* LDR helper (lit addr-hb addr-lb ldr) */
case ',': return 3; /* lit2 addr-hb addr-lb */
case '.': return 2; /* addr-hb addr-lb */
case '^': return 2; /* Relative jump: lit addr-offset */
case '=': return 4 - (findlabeladdr(w + 1) < 0x0100); /* POK/STR helper (lit addr(1/2) str) */
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 2; /* addr-hb addr-lb */
case '^': return 2; /* Relative jump: lit addr-offset */
case '#': return (slen(w + 1) == 2 ? 2 : 3);
}
if((m = findmacro(w))) {
@ -298,15 +298,25 @@ parsetoken(char *w)
} else if(w[0] == '=' && (l = findlabel(w + 1))) {
if(!findlabellen(w + 1) || findlabellen(w + 1) > 2)
return error("Invalid store helper", w);
pushshort(findlabeladdr(w + 1), 1);
pushbyte(findopcode(findlabellen(w + 1) == 2 ? "STR2" : "POK2"), 0);
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);
pushbyte(findopcode(findlabellen(w + 1) == 2 ? "STR2" : "POK2"), 0);
}
l->refs++;
return 1;
} else if(w[0] == '~' && (l = findlabel(w + 1))) {
if(!findlabellen(w + 1) || findlabellen(w + 1) > 2)
return error("Invalid load helper", w);
pushshort(findlabeladdr(w + 1), 1);
pushbyte(findopcode(findlabellen(w + 1) == 2 ? "LDR2" : "PEK2"), 0);
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);
pushbyte(findopcode(findlabellen(w + 1) == 2 ? "LDR2" : "PEK2"), 0);
}
l->refs++;
return 1;
} else if((op = findopcode(w)) || scmp(w, "BRK", 4)) {