diff --git a/src/devices/console.c b/src/devices/console.c index fda5443..8683e61 100644 --- a/src/devices/console.c +++ b/src/devices/console.c @@ -49,11 +49,11 @@ static pid_t child_pid; * (other bits ignored for now ) */ -#define CMD_LIVE 0x15 // 0x00 not started, 0x01 running, 0xff dead -#define CMD_EXIT 0x16 // if dead, exit code of process -#define CMD_ADDR 0x1c // address to read command args from -#define CMD_MODE 0x1e // mode to execute, 0x00 to 0x07 -#define CMD_EXEC 0x1f // write to execute programs, etc +#define CMD_LIVE 0x15 /* 0x00 not started, 0x01 running, 0xff dead */ +#define CMD_EXIT 0x16 /* if dead, exit code of process */ +#define CMD_ADDR 0x1c /* address to read command args from */ +#define CMD_MODE 0x1e /* mode to execute, 0x00 to 0x07 */ +#define CMD_EXEC 0x1f /* write to execute programs, etc */ /* call after we're sure the process has exited */ static void @@ -76,10 +76,10 @@ clean_after_child(void) static void start_fork_pipe(void) { - fflush(stdout); pid_t pid; pid_t parent_pid = getpid(); int addr = PEEK2(&uxn.dev[CMD_ADDR]); + fflush(stdout); if(child_mode & 0x08) { uxn.dev[CMD_EXIT] = uxn.dev[CMD_LIVE] = 0x00; return; @@ -110,10 +110,11 @@ start_fork_pipe(void) #ifdef __linux__ int r = prctl(PR_SET_PDEATHSIG, SIGTERM); - if (r == -1) { perror(0); exit(6); } - // test in case the original parent exited just - // before the prctl() call - if (getppid() != parent_pid) exit(13); + if(r == -1) { + perror(0); + exit(6); + } + if(getppid() != parent_pid) exit(13); #endif if(child_mode & 0x01) { diff --git a/src/uxn.c b/src/uxn.c index 275b829..91ce7e4 100644 --- a/src/uxn.c +++ b/src/uxn.c @@ -12,14 +12,14 @@ WITH REGARD TO THIS SOFTWARE. */ #define OPC(opc, init, body) {\ - case 0x00|opc: {enum{_2=0,_r=0};init body;} break;\ - case 0x20|opc: {enum{_2=1,_r=0};init body;} break;\ - case 0x40|opc: {enum{_2=0,_r=1};init body;} break;\ - case 0x60|opc: {enum{_2=1,_r=1};init body;} break;\ - case 0x80|opc: {enum{_2=0,_r=0};int k=uxn.wst.ptr;init uxn.wst.ptr= k;body;} break;\ - case 0xa0|opc: {enum{_2=1,_r=0};int k=uxn.wst.ptr;init uxn.wst.ptr= k;body;} break;\ - case 0xc0|opc: {enum{_2=0,_r=1};int k=uxn.rst.ptr;init uxn.rst.ptr= k;body;} break;\ - case 0xe0|opc: {enum{_2=1,_r=1};int k=uxn.rst.ptr;init uxn.rst.ptr= k;body;} break;\ + case 0x00|opc: {const int _2=0,_r=0;init body;} break;\ + case 0x20|opc: {const int _2=1,_r=0;init body;} break;\ + case 0x40|opc: {const int _2=0,_r=1;init body;} break;\ + case 0x60|opc: {const int _2=1,_r=1;init body;} break;\ + case 0x80|opc: {const int _2=0,_r=0;int k=uxn.wst.ptr;init uxn.wst.ptr= k;body;} break;\ + case 0xa0|opc: {const int _2=1,_r=0;int k=uxn.wst.ptr;init uxn.wst.ptr= k;body;} break;\ + case 0xc0|opc: {const int _2=0,_r=1;int k=uxn.rst.ptr;init uxn.rst.ptr= k;body;} break;\ + case 0xe0|opc: {const int _2=1,_r=1;int k=uxn.rst.ptr;init uxn.rst.ptr= k;body;} break;\ } /* Microcode */ @@ -58,7 +58,7 @@ uxn_eval(Uint16 pc) /* L2r */ case 0xe0: INC(rst) = uxn.ram[pc++]; /* LIr */ case 0xc0: INC(rst) = uxn.ram[pc++]; break; /* INC */ OPC(0x01, POx(a), PUx(a + 1)) - /* POP */ OPC(0x02, REM, 0) + /* POP */ OPC(0x02, REM, {}) /* NIP */ OPC(0x03, GET(x) REM,PUT(x)) /* SWP */ OPC(0x04, GET(x) GET(y),PUT(x) PUT(y)) /* ROT */ OPC(0x05, GET(x) GET(y) GET(z),PUT(y) PUT(x) PUT(z)) diff --git a/src/uxn11.c b/src/uxn11.c index 318a87d..e9f59fc 100644 --- a/src/uxn11.c +++ b/src/uxn11.c @@ -200,7 +200,7 @@ display_init(void) char empty[] = {0}; Pixmap bitmap; Cursor blank; - XClassHint class = { "uxn11", "Uxn" }; + XClassHint class = {"uxn11", "Uxn"}; display = XOpenDisplay(NULL); if(!display) return system_error("init", "Display failed"); @@ -271,7 +271,7 @@ main(int argc, char **argv) int i = 1; char *rom; if(i != argc && argv[i][0] == '-' && argv[i][1] == 'v') { - fprintf(stdout, "Uxn11 - Varvara Emulator, 25 Aug 2024.\n"); + fprintf(stdout, "Uxn11 - Varvara Emulator, 29 Aug 2024.\n"); exit(0); } rom = i == argc ? "boot.rom" : argv[i++]; diff --git a/src/uxnasm.c b/src/uxnasm.c index 89b726a..80beaa0 100644 --- a/src/uxnasm.c +++ b/src/uxnasm.c @@ -61,7 +61,7 @@ static int parse(char *w, FILE *f, Context *ctx); static char * push(char *s, char c) { - char *d = dict; + char *d; for(d = dict; d < dictnext; d++) { char *ss = s, *dd = d, a, b; while((a = *dd++) == (b = *ss++)) @@ -126,7 +126,7 @@ walkmacro(Item *m, Context *ctx) char *dataptr = m->data, *_token = token; while((c = *dataptr++)) { if(c < 0x21) { - *_token++ = 0x00; + *_token = 0x00; if(token[0] && !parse(token, NULL, ctx)) return 0; _token = token; } else if(_token - token < 0x2f) @@ -144,7 +144,7 @@ walkfile(FILE *f, Context *ctx) char *_token = token; while(f && fread(&c, 1, 1, f)) { if(c < 0x21) { - *_token++ = 0x00; + *_token = 0x00; if(token[0] && !parse(token, f, ctx)) return 0; if(c == 0xa) ctx->line++; _token = token; @@ -153,7 +153,7 @@ walkfile(FILE *f, Context *ctx) else return error_asm("Token size exceeded"); } - *_token++ = 0; + *_token = 0; return parse(token, f, ctx); } @@ -293,7 +293,7 @@ static int assemble(char *filename) { FILE *f; - int res = 0; + int res; Context ctx; ctx.line = 1; ctx.path = push(filename, 0); @@ -415,7 +415,7 @@ main(int argc, char *argv[]) { ptr = PAGE; copy("on-reset", scope, 0); - if(argc == 2 && scmp(argv[1], "-v", 2)) return !printf("Uxnasm - Uxntal Assembler, 25 Aug 2024.\n"); + if(argc == 2 && scmp(argv[1], "-v", 2)) return !printf("Uxnasm - Uxntal Assembler, 29 Aug 2024.\n"); if(argc != 3) return error_top("usage", "uxnasm [-v] input.tal output.rom"); if(!assemble(argv[1])) return 1; if(!resolve(argv[2])) return 1; diff --git a/src/uxncli.c b/src/uxncli.c index 6d72c80..67b6e36 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -69,7 +69,7 @@ main(int argc, char **argv) int i = 1; char *rom; if(i != argc && argv[i][0] == '-' && argv[i][1] == 'v') { - fprintf(stdout, "Uxncli - Console Varvara Emulator, 25 Aug 2024.\n"); + fprintf(stdout, "Uxncli - Console Varvara Emulator, 29 Aug 2024.\n"); exit(0); } rom = i == argc ? "boot.rom" : argv[i++];