From cb73e63eb4ca375373f135f60c7aaaeb267f5a6a Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Thu, 22 Feb 2024 15:47:44 -0800 Subject: [PATCH 1/5] Added boot.rom --- boot.rom | Bin 0 -> 16226 bytes makefile | 12 +++++------- src/uxn11.c | 14 ++++++-------- 3 files changed, 11 insertions(+), 15 deletions(-) create mode 100644 boot.rom diff --git a/boot.rom b/boot.rom new file mode 100644 index 0000000000000000000000000000000000000000..37ad1b6b2d130a9255a7b2e130d30526500d71d0 GIT binary patch literal 16226 zcmch84SZF_nfG(L3FhP`xd{PsLq2aXl9Pb=QEez-TiaUa1`>@u=B6Pa zSQ-cY`BB#{u1oD|YaQ*buWMWBuT`toZPTu`UCaAoTi0&gDzQbNs3ZmuRLp(<&zyS$ z*w)|f{(kQ};hyu%%ri63JYVz7%t0A#($}t5hh?B${U9uZ?dpGpWvE>x?iP_JRmL?} zWsJGPn-Yt!P>C-Knh}M2iB_jaQ={o%_mJ5;+&_{U9UQvST)TDSX#X|Ao~`Bun}#-w z^lvcNr26^>M>htWn#@)GeP&Z*Qwte4wmodC3!apo#-uGhI~tR{OYOK^&|F)YP!W>k zmsXdu`V<9|$wwy_nG}dWs)#zOTVuv;X6BVxADY&7NY7H0nX0x5&X1!vpq&*LR4=H) zq$rng|J*nx-F8e8eg=LnyXN6=)uP^VTNM3}hj=tmS=lm~Ojp~AeDa}o5 zMVE8VD(ZnKMCKoK^V>yeT23~J%$KY=MJlmIlx&X+*X}b~e$FbYa#~`JX!%*)a*Y*w zLM1*TN>-!6*Uo70b*pHuZczAJ-C&6o`axV}GMM&7JLQsqN#}vpX))(1lb!}ND&~CG zr0)T`QOtSJBpc9HG3VeU=G%{}D59vvD*V1KYIIjyg%@bB^7E<@6I!5azoLt(rc^BE6p6wctfH;DwEBdK zg>$90RkWT<#mr~Lob`ersy@!gg>j9lDyudO%r!0wS6W5qsIuK+?i1V1!tE|d8#xs# zacbjM(E`RR<|j-wL`}65*^mu<7z=r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ixbd z$@mPs|NcoBp&o;+5rLAE#&dwqmR9H&L;(NT)5H9MSsZZqgQ|lkbUj2+TH*Y4Wzz@c zb?}7qcQTuRt(yW}kCE$=>E{Yy>w2I&W9VGgt{^eay8RlLU%CzJD2lbba(ww~@?u<0 zIeGn$^x5z8FdYyAFEp$`&dVVON+(P%fWU@5I{EwsI%VgfTWrVLm&qXHM-mgmI$<9F zBYQU-BQV@r)+{R?AFnKBa@^zdgvxInpMWWHa%U9?EM)(4Dvh)Dz-Y9xL4Vxre31NE z0QfqO78=Ou%|s3$!+;E6Uao?O_CMRVYcjU?Fh1y!670vz8V>yb@;{nlJTU7VsNb5f z(@HSwTn>oLBS*eY;ThOd!^5mb!?XBV|C7tJ5zoQ^PRC{5qsY$=h;e|*xcvGvf6I6Q zFp}}I>5P8CL!D+TbuWMRa5_ivDLXwACs+Q#_w_$^{&Ltnj^Wovj2HZaui|>H%f3LH zoHzk*lznAsmE)Q|IWbXoc2RL@>Ace1IGOA3JJ7Lb`np{InVEME+^2hVN~Gm%bhK9D zQCeDB6e=pm$Z#O|9U8gk-FKHg*EHK+12gaB^13xT(e3f92s@^7PL~7xpXv8!mKV5~ zKYNaJg$!h}?u0yf5_&r^brJ#AU+W(T|K(&9Y2R$P z!x#rij(?Y%%ZaHITPm`8-gS1^%S;&0`st@JcGh8Qy_nSpM;#nJkP{OSnNB(Rj&)|KPj-jSOwhrIaBazecXIfVbr-rC-APN#NThRf~s`Pn}F2+`cG(+dAD D*k6y- literal 0 HcmV?d00001 diff --git a/makefile b/makefile index 7e2c675..e007864 100644 --- a/makefile +++ b/makefile @@ -5,18 +5,16 @@ EMU_src=${CLI_src} src/devices/screen.c src/devices/controller.c src/devices/mou RELEASE_flags=-DNDEBUG -O2 -g0 -s DEBUG_flags=-std=c89 -D_POSIX_C_SOURCE=199309L -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined -.PHONY: all debug dest rom run test install uninstall format clean +.PHONY: all debug dest run test install uninstall format clean all: dest bin/uxnasm bin/uxncli bin/uxn11 dest: @ mkdir -p bin -rom: - @ ./bin/uxnasm etc/screen.bounds.tal bin/res.rom -run: all bin/uxnasm bin/uxncli bin/uxn11 rom - @ ./bin/uxn11 bin/res.rom +run: all bin/uxnasm bin/uxncli bin/uxn11 + @ ./bin/uxn11 test: bin/uxnasm bin/uxncli bin/uxn11 - @ ./bin/uxnasm && ./bin/uxncli && ./bin/uxn11 && ./bin/uxnasm -v && ./bin/uxncli -v && ./bin/uxn11 -v + @ ./bin/uxnasm -v && ./bin/uxncli -v && ./bin/uxn11 -v @ ./bin/uxnasm etc/opctest.tal bin/opctest.rom @ ./bin/uxncli bin/opctest.rom install: bin/uxnasm bin/uxncli bin/uxn11 @@ -26,7 +24,7 @@ uninstall: format: @ clang-format -i src/uxnasm.c src/uxncli.c src/uxn11.c src/devices/* clean: - @ rm -f bin/uxnasm bin/uxncli bin/uxn11 bin/polycat.rom bin/polycat.rom.sym + @ rm -fr bin bin/uxnasm: src/uxnasm.c @ cc ${RELEASE_flags} ${CFLAGS} src/uxnasm.c -o bin/uxnasm diff --git a/src/uxn11.c b/src/uxn11.c index 6e91401..b52a95f 100644 --- a/src/uxn11.c +++ b/src/uxn11.c @@ -265,16 +265,14 @@ main(int argc, char **argv) { Uxn u = {0}; int i = 1; - if(i == argc) { - fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]); - return 0; - } - if(argv[i][0] == '-' && argv[i][1] == 'v') { - fprintf(stdout, "Uxn11 - Varvara Emulator, 14 Feb 2023.\n"); + char *rom; + if(i != argc && argv[i][0] == '-' && argv[i][1] == 'v') { + fprintf(stdout, "Uxn11 - Varvara Emulator, 22 Feb 2023.\n"); i++; } - if(!system_boot(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++])) { - fprintf(stdout, "Could not boot.\n"); + rom = i == argc ? "boot.rom" : argv[i++]; + if(!system_boot(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), rom)) { + fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]); return 0; } if(!display_init()) { From b9a79eca1905a53d25931e795f9d06c42719aa4c Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sat, 24 Feb 2024 08:46:18 -0800 Subject: [PATCH 2/5] (uxnasm)Passing uxntal scope requirements --- etc/coverage.tal | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ src/uxnasm.c | 9 +++--- 2 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 etc/coverage.tal diff --git a/etc/coverage.tal b/etc/coverage.tal new file mode 100644 index 0000000..a75fdf1 --- /dev/null +++ b/etc/coverage.tal @@ -0,0 +1,77 @@ +( test file ) + +|0100 @program + + #01 ?{ ( skip ) #ffff } + !{ ( skip ) #ffff } + { ( skip ) #ffff } POP2r + + ( nested lambda ) + { { "hello 0a $1 } STH2r !print-str } STH2r JSR2 + + ( function application ) + { 01 02 03 04 05 } STH2r { LIT "0 ADD #18 DEO #0a18 DEO JMP2r } STH2r foreach + + ( get lambda length ) + { "Dindeldums $1 } STH2r get-lambda-length #0a18 DEO + + ( allocated string ) + ;hello-word print-str + + #800f DEO + +BRK + +( +@| test label inheritance ) + +@object + +&x $1 &y $1 + +&get-x ( -- x ) + ,&x LDR + JMP2r + +@object/get-y ( -- y ) + ,&y LDR + JMP2r + +( raw lambda length ) +_{ 01 02 03 } + +@get-lambda-length ( lambda* -- length* ) + #0002 SUB2 LDA2 +JMP2r + +@print-str ( str* -- ) + &while ( -- ) + ( send ) LDAk #18 DEO + ( loop ) INC2 LDAk ?&while + POP2 + +JMP2r + +@foreach ( arr* fn* -- ) + STH2 + DUP2 + DUP2 #0002 SUB2 LDA2 ADD2 + SWP2 + &l + LDAk STH2kr JSR2 + INC2 NEQ2k ?&l + POP2 POP2 POP2r +JMP2r + +@ ( short* -- ) + #2710 [ LIT2r 00fb ] + &w ( -- ) + DIV2k #000a DIV2k MUL2 SUB2 SWPr EQUk OVR STHkr EQU AND ?&>skip + DUP [ LIT "0 ] ADD #19 DEO + INCr &>skip + POP2 #000a DIV2 SWPr INCr STHkr ?&w + POP2r POP2 POP2 JMP2r + +$20 @label2 + +@hello-word "Hello 20 "World! 0a $1 diff --git a/src/uxnasm.c b/src/uxnasm.c index f80d63b..2f7b8f7 100644 --- a/src/uxnasm.c +++ b/src/uxnasm.c @@ -320,7 +320,10 @@ parse(char *w, FILE *f) case '@': /* label */ if(!makelabel(w + 1)) return error("Invalid label", w); - scpy(w + 1, p.scope, 0x40); + i = 0; + while(w[i + 1] != '/' && i < 0x3e && (p.scope[i] = w[i + 1])) + i++; + p.scope[i] = '\0'; break; case '&': /* sublabel */ if(!sublabel(subw, p.scope, w + 1) || !makelabel(subw)) @@ -346,7 +349,6 @@ parse(char *w, FILE *f) case '.': /* literal byte zero-page */ makereference(p.scope, w + 1, w[0], p.ptr + 1); return writelitbyte(0xff); - case ':': case '=': /* raw short absolute */ makereference(p.scope, w + 1, w[0], p.ptr); return writeshort(0xffff, 0); @@ -420,7 +422,6 @@ resolve(void) p.data[r->addr] = l->addr & 0xff; l->refs++; break; - case ':': case '=': case ';': if(!(l = findlabel(r->name))) @@ -501,7 +502,7 @@ main(int argc, char *argv[]) if(argc == 1) return error("usage", "uxnasm [-v] input.tal output.rom"); if(argv[1][0] == '-' && argv[1][1] == 'v') - return !fprintf(stdout, "Uxnasm - Uxntal Assembler, 27 Oct 2023.\n"); + return !fprintf(stdout, "Uxnasm - Uxntal Assembler, 24 Feb 2024.\n"); if(!(src = fopen(argv[1], "r"))) return !error("Invalid input", argv[1]); if(!assemble(src)) From a55b07e1db342096942f6248217d70707f658a0c Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sun, 25 Feb 2024 16:06:14 -0800 Subject: [PATCH 3/5] (uxnasm) Added support for partial label jsi --- etc/coverage.tal | 12 +++++++----- src/uxnasm.c | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/etc/coverage.tal b/etc/coverage.tal index a75fdf1..122c2a3 100644 --- a/etc/coverage.tal +++ b/etc/coverage.tal @@ -22,21 +22,23 @@ BRK -( +( @| test label inheritance ) -@object - -&x $1 &y $1 +@Object &x $1 &y $1 &get-x ( -- x ) ,&x LDR JMP2r -@object/get-y ( -- y ) +@Object/get-y ( -- y ) ,&y LDR JMP2r +@Object/get-both ( -- x y ) + /get-x /get-y + JMP2r + ( raw lambda length ) _{ 01 02 03 } diff --git a/src/uxnasm.c b/src/uxnasm.c index 2f7b8f7..e2a1a00 100644 --- a/src/uxnasm.c +++ b/src/uxnasm.c @@ -195,7 +195,7 @@ makereference(char *scope, char *label, char rune, Uint16 addr) if(label[0] == '{') { p.lambda_stack[p.lambda_ptr++] = p.lambda_count; scpy(makelambda(p.lambda_count++), r->name, 0x40); - } else if(label[0] == '&') { + } else if(label[0] == '&' || label[0] == '/') { if(!sublabel(subw, scope, label + 1)) return error("Invalid sublabel", label); scpy(subw, r->name, 0x40); @@ -321,7 +321,7 @@ parse(char *w, FILE *f) if(!makelabel(w + 1)) return error("Invalid label", w); i = 0; - while(w[i + 1] != '/' && i < 0x3e && (p.scope[i] = w[i + 1])) + while(w[i + 1] != '/' && i < 0x3e && (p.scope[i] = w[i + 1])) i++; p.scope[i] = '\0'; break; @@ -502,7 +502,7 @@ main(int argc, char *argv[]) if(argc == 1) return error("usage", "uxnasm [-v] input.tal output.rom"); if(argv[1][0] == '-' && argv[1][1] == 'v') - return !fprintf(stdout, "Uxnasm - Uxntal Assembler, 24 Feb 2024.\n"); + return !fprintf(stdout, "Uxnasm - Uxntal Assembler, 25 Feb 2024.\n"); if(!(src = fopen(argv[1], "r"))) return !error("Invalid input", argv[1]); if(!assemble(src)) From c7ef5230b4ee0423d5492fd1c065c8cdf9449218 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sun, 25 Feb 2024 17:21:30 -0800 Subject: [PATCH 4/5] Disallow runic labels --- src/uxnasm.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/uxnasm.c b/src/uxnasm.c index e2a1a00..3b902cc 100644 --- a/src/uxnasm.c +++ b/src/uxnasm.c @@ -55,6 +55,8 @@ static char ops[][4] = { "ADD", "SUB", "MUL", "DIV", "AND", "ORA", "EOR", "SFT" }; +static char *runes = "|$@&,_.-;=!?#\"%~"; + static int scmp(char *a, char *b, int len) { int i = 0; while(a[i] == b[i]) if(!a[i] || ++i >= len) return 1; return 0; } /* string compare */ static int sihx(char *s) { int i = 0; char c; while((c = s[i++])) if(!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f')) return 0; return i > 1; } /* string is hexadecimal */ static int shex(char *s) { int n = 0, i = 0; char c; while((c = s[i++])) if(c >= '0' && c <= '9') n = n * 16 + (c - '0'); else if(c >= 'a' && c <= 'f') n = n * 16 + 10 + (c - 'a'); return n; } /* string to num */ @@ -156,6 +158,15 @@ makemacro(char *name, FILE *f) return 1; } +static int +isrune(char c) +{ + char cc, *r = runes; + while((cc = *r++)) + if(c == cc) return 1; + return 0; +} + static int makelabel(char *name) { @@ -166,6 +177,8 @@ makelabel(char *name) return error("Label name is hex number", name); if(findopcode(name) || scmp(name, "BRK", 4) || !slen(name)) return error("Label name is invalid", name); + if(isrune(name[0])) + return error("Label name is runic", name); if(p.label_len == 0x400) return error("Labels limit exceeded", name); l = &p.labels[p.label_len++]; From c7d3a410ab1ac4c32290584ab8f43b0a5d81547a Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sun, 25 Feb 2024 17:36:33 -0800 Subject: [PATCH 5/5] Fixed issue with no-output --- makefile | 2 +- src/uxnasm.c | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/makefile b/makefile index e007864..6d59e68 100644 --- a/makefile +++ b/makefile @@ -17,7 +17,7 @@ test: bin/uxnasm bin/uxncli bin/uxn11 @ ./bin/uxnasm -v && ./bin/uxncli -v && ./bin/uxn11 -v @ ./bin/uxnasm etc/opctest.tal bin/opctest.rom @ ./bin/uxncli bin/opctest.rom -install: bin/uxnasm bin/uxncli bin/uxn11 +install: all bin/uxnasm bin/uxncli bin/uxn11 @ cp bin/uxn11 bin/uxnasm bin/uxncli ~/bin/ uninstall: @ rm -f ~/bin/uxn11 ~/bin/uxnasm ~/bin/uxncli diff --git a/src/uxnasm.c b/src/uxnasm.c index 3b902cc..d1dcf09 100644 --- a/src/uxnasm.c +++ b/src/uxnasm.c @@ -520,9 +520,7 @@ main(int argc, char *argv[]) return !error("Invalid input", argv[1]); if(!assemble(src)) return !error("Assembly", "Failed to assemble rom."); - if(scmp(argv[2], "-", 2)) - dst = stdout; - else if(!(dst = fopen(argv[2], "wb"))) + if(!(dst = fopen(argv[2], "wb"))) return !error("Invalid Output", argv[2]); if(p.length <= TRIM) return !error("Assembly", "Output rom is empty.");