From ea8f512fcd3d4ec436f88a93d3708f0e1bd41c86 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Thu, 28 Mar 2024 09:30:23 -0700 Subject: [PATCH] (uxnasm)Check for output size after resolving symbols --- src/uxnasm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/uxnasm.c b/src/uxnasm.c index 70b9351..4ecc1ea 100644 --- a/src/uxnasm.c +++ b/src/uxnasm.c @@ -377,7 +377,7 @@ resolve(void) } l->refs++; } - return 1; + return !length ? error_top("Assembly", "Output rom is empty.") : 1; } static void @@ -424,10 +424,8 @@ main(int argc, char *argv[]) scpy("on-reset", scope, 0x40); if(argc == 1) return error_top("usage", "uxnasm [-v] input.tal output.rom"); if(scmp(argv[1], "-v", 2)) return !fprintf(stdout, "Uxnasm - Uxntal Assembler, 28 Mar 2024.\n"); - if(!assemble(argv[1])) return !error_top("Assembly", "Failed to assemble rom."); - if(!resolve()) return !error_top("Assembly", "Failed to resolve symbols."); + if(!assemble(argv[1]) || !resolve()) return !error_top("Assembly", "Failed to assemble rom."); if(!(dst = fopen(argv[2], "wb"))) return !error_top("Invalid Output", argv[2]); - if(length <= PAGE) return !error_top("Assembly", "Output rom is empty."); review(argv[2]); fwrite(data + PAGE, length - PAGE, 1, dst); writesym(argv[2]);