~rabbits/uxn

uxnasm: Allow overriding opcodes with macros v1 PROPOSED

easrng: 1
 uxnasm: Allow overriding opcodes with macros

 1 files changed, 10 insertions(+), 9 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~rabbits/uxn/patches/44012/mbox | git am -3
Learn more about email & git

[PATCH] uxnasm: Allow overriding opcodes with macros Export this patch

---
 src/uxnasm.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/uxnasm.c b/src/uxnasm.c
index d8f809e..29f81e5 100644
--- a/src/uxnasm.c
+++ b/src/uxnasm.c
@@ -138,7 +138,7 @@ makemacro(char *name, FILE *f)
        return error("Macro duplicate", name);
    if(sihx(name) && slen(name) % 2 == 0)
        return error("Macro name is hex number", name);
    if(findopcode(name) || scmp(name, "BRK", 4) || !slen(name))
    if(!slen(name))
        return error("Macro name is invalid", name);
    if(p.macro_len == 0x100)
        return error("Macros limit exceeded", name);
@@ -372,8 +372,15 @@ parse(char *w, FILE *f)
    case ']':
        if(slen(w) == 1) break; /* else fallthrough */
    default:
        /* macro */
        if((m = findmacro(w))) {
            for(i = 0; i < m->len; i++)
                if(!parse(m->items[i], f))
                    return 0;
            return 1;
        }
        /* opcode */
        if(findopcode(w) || scmp(w, "BRK", 4))
        else if(findopcode(w) || scmp(w, "BRK", 4))
            return writeopcode(w);
        /* raw byte */
        else if(sihx(w) && slen(w) == 2)
@@ -381,13 +388,7 @@ parse(char *w, FILE *f)
        /* raw short */
        else if(sihx(w) && slen(w) == 4)
            return writeshort(shex(w), 0);
        /* macro */
        else if((m = findmacro(w))) {
            for(i = 0; i < m->len; i++)
                if(!parse(m->items[i], f))
                    return 0;
            return 1;
        } else {
        else {
            makereference(p.scope, w, ' ', p.ptr + 1);
            return writebyte(0x60) && writeshort(0xffff, 0);
        }
-- 
2.30.2