mirror of https://git.sr.ht/~rabbits/uxn
(uxnasm) Removed writelitbyte
This commit is contained in:
parent
0c13a40916
commit
3777f30281
32
src/uxnasm.c
32
src/uxnasm.c
|
@ -220,7 +220,7 @@ makesublabel(char *src, char *scope, char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
makereference(char *scope, char *label, char rune, Uint16 addr)
|
addref(char *scope, char *label, char rune, Uint16 addr)
|
||||||
{
|
{
|
||||||
char subw[0x40], parent[0x40];
|
char subw[0x40], parent[0x40];
|
||||||
Reference *r;
|
Reference *r;
|
||||||
|
@ -271,15 +271,7 @@ writeopcode(char *w)
|
||||||
static int
|
static int
|
||||||
writeshort(Uint16 s, int lit)
|
writeshort(Uint16 s, int lit)
|
||||||
{
|
{
|
||||||
if(lit)
|
return (lit ? writebyte(findopcode("LIT2")) : 1) && writebyte(s >> 8) && writebyte(s & 0xff);
|
||||||
if(!writebyte(findopcode("LIT2"))) return 0;
|
|
||||||
return writebyte(s >> 8) && writebyte(s & 0xff);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
writelitbyte(Uint8 b)
|
|
||||||
{
|
|
||||||
return writebyte(findopcode("LIT")) && writebyte(b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -366,29 +358,29 @@ parse(char *w, FILE *f)
|
||||||
break;
|
break;
|
||||||
case '#': /* literals hex */
|
case '#': /* literals hex */
|
||||||
if(sihx(w + 1) && slen(w) == 3)
|
if(sihx(w + 1) && slen(w) == 3)
|
||||||
return writelitbyte(shex(w + 1));
|
return writebyte(findopcode("LIT")) && writebyte(shex(w + 1));
|
||||||
else if(sihx(w + 1) && slen(w) == 5)
|
else if(sihx(w + 1) && slen(w) == 5)
|
||||||
return writeshort(shex(w + 1), 1);
|
return writeshort(shex(w + 1), 1);
|
||||||
else
|
else
|
||||||
return error_asm("Invalid hex literal", w);
|
return error_asm("Invalid hex literal", w);
|
||||||
break;
|
break;
|
||||||
case '_': /* raw byte relative */
|
case '_': /* raw byte relative */
|
||||||
return makereference(p.scope, w + 1, w[0], p.ptr) && writebyte(0xff);
|
return addref(p.scope, w + 1, w[0], p.ptr) && writebyte(0xff);
|
||||||
case ',': /* literal byte relative */
|
case ',': /* literal byte relative */
|
||||||
return makereference(p.scope, w + 1, w[0], p.ptr + 1) && writelitbyte(0xff);
|
return addref(p.scope, w + 1, w[0], p.ptr + 1) && writebyte(findopcode("LIT")) && writebyte(0xff);
|
||||||
case '-': /* raw byte absolute */
|
case '-': /* raw byte absolute */
|
||||||
return makereference(p.scope, w + 1, w[0], p.ptr) && writebyte(0xff);
|
return addref(p.scope, w + 1, w[0], p.ptr) && writebyte(0xff);
|
||||||
case '.': /* literal byte zero-page */
|
case '.': /* literal byte zero-page */
|
||||||
return makereference(p.scope, w + 1, w[0], p.ptr + 1) && writelitbyte(0xff);
|
return addref(p.scope, w + 1, w[0], p.ptr + 1) && writebyte(findopcode("LIT")) && writebyte(0xff);
|
||||||
case ':': fprintf(stderr, "Deprecated rune %s, use =%s\n", w, w + 1);
|
case ':': fprintf(stderr, "Deprecated rune %s, use =%s\n", w, w + 1);
|
||||||
case '=': /* raw short absolute */
|
case '=': /* raw short absolute */
|
||||||
return makereference(p.scope, w + 1, w[0], p.ptr) && writeshort(0xffff, 0);
|
return addref(p.scope, w + 1, w[0], p.ptr) && writeshort(0xffff, 0);
|
||||||
case ';': /* literal short absolute */
|
case ';': /* literal short absolute */
|
||||||
return makereference(p.scope, w + 1, w[0], p.ptr + 1) && writeshort(0xffff, 1);
|
return addref(p.scope, w + 1, w[0], p.ptr + 1) && writeshort(0xffff, 1);
|
||||||
case '?': /* JCI */
|
case '?': /* JCI */
|
||||||
return makereference(p.scope, w + 1, w[0], p.ptr + 1) && writebyte(0x20) && writeshort(0xffff, 0);
|
return addref(p.scope, w + 1, w[0], p.ptr + 1) && writebyte(0x20) && writeshort(0xffff, 0);
|
||||||
case '!': /* JMI */
|
case '!': /* JMI */
|
||||||
return makereference(p.scope, w + 1, w[0], p.ptr + 1) && writebyte(0x40) && writeshort(0xffff, 0);
|
return addref(p.scope, w + 1, w[0], p.ptr + 1) && writebyte(0x40) && writeshort(0xffff, 0);
|
||||||
case '"': /* raw string */
|
case '"': /* raw string */
|
||||||
i = 0;
|
i = 0;
|
||||||
while((c = w[++i]))
|
while((c = w[++i]))
|
||||||
|
@ -418,7 +410,7 @@ parse(char *w, FILE *f)
|
||||||
return 0;
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
} else
|
} else
|
||||||
return makereference(p.scope, w, ' ', p.ptr + 1) && writebyte(0x60) && writeshort(0xffff, 0);
|
return addref(p.scope, w, ' ', p.ptr + 1) && writebyte(0x60) && writeshort(0xffff, 0);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue