uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit f59b214ac16fea892426faa6468ebf68acfa7f27
parent 02ecc2ee7d412a92701e48a33b9b67ad26bf98a8
Author: neauoire <aliceffekt@gmail.com>
Date:   Thu, 10 Nov 2022 20:54:53 -0800

Added _rune

Diffstat:
Msrc/uxnasm.c | 40++++++++++++++++++++++++++--------------
1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/src/uxnasm.c b/src/uxnasm.c @@ -303,26 +303,30 @@ parse(char *w, FILE *f) if(!writeshort(shex(w + 1), 1)) return 0; } break; - case '.': /* literal byte zero-page */ + case '_': /* raw byte relative */ makereference(p.scope, w, p.ptr); - if(!writelitbyte(0xff)) return 0; + if(!writebyte(0xff)) return 0; break; case ',': /* literal byte relative */ makereference(p.scope, w, p.ptr); if(!writelitbyte(0xff)) return 0; break; - case ';': /* literal short absolute */ + case '-': /* raw byte absolute */ makereference(p.scope, w, p.ptr); - if(!writeshort(0xffff, 1)) return 0; + if(!writebyte(0xff)) return 0; + break; + case '.': /* literal byte zero-page */ + makereference(p.scope, w, p.ptr); + if(!writelitbyte(0xff)) return 0; break; case ':': /* raw short absolute */ case '=': makereference(p.scope, w, p.ptr); if(!writeshort(0xffff, 0)) return 0; break; - case '-': /* raw byte absolute */ + case ';': /* literal short absolute */ makereference(p.scope, w, p.ptr); - if(!writebyte(0xff)) return 0; + if(!writeshort(0xffff, 1)) return 0; break; case '"': /* raw string */ i = 0; @@ -365,10 +369,12 @@ resolve(void) for(i = 0; i < p.rlen; i++) { Reference *r = &p.refs[i]; switch(r->rune) { - case '.': + case '_': if(!(l = findlabel(r->name))) - return error("Unknown zero-page reference", r->name); - p.data[r->addr + 1] = l->addr & 0xff; + return error("Unknown relative reference", r->name); + p.data[r->addr] = (Sint8)(l->addr - r->addr - 2); + if((Sint8)p.data[r->addr] != (l->addr - r->addr - 2)) + return error("Relative reference is too far", r->name); l->refs++; break; case ',': @@ -379,11 +385,16 @@ resolve(void) return error("Relative reference is too far", r->name); l->refs++; break; - case ';': + case '-': if(!(l = findlabel(r->name))) return error("Unknown absolute reference", r->name); - p.data[r->addr + 1] = l->addr >> 0x8; - p.data[r->addr + 2] = l->addr & 0xff; + p.data[r->addr] = l->addr & 0xff; + l->refs++; + break; + case '.': + if(!(l = findlabel(r->name))) + return error("Unknown zero-page reference", r->name); + p.data[r->addr + 1] = l->addr & 0xff; l->refs++; break; case ':': @@ -394,10 +405,11 @@ resolve(void) p.data[r->addr + 1] = l->addr & 0xff; l->refs++; break; - case '-': + case ';': if(!(l = findlabel(r->name))) return error("Unknown absolute reference", r->name); - p.data[r->addr] = l->addr & 0xff; + p.data[r->addr + 1] = l->addr >> 0x8; + p.data[r->addr + 2] = l->addr & 0xff; l->refs++; break; default: