From 7c24e9a9b02b04dcaf9507acb94091ea70a2c02d Mon Sep 17 00:00:00 2001 From: Xavi Del Campo Date: Fri, 31 Jan 2020 10:32:23 +0100 Subject: Imported pristine psxsdk-20190410 from official repo --- tools/spasm/error.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tools/spasm/error.c (limited to 'tools/spasm/error.c') diff --git a/tools/spasm/error.c b/tools/spasm/error.c new file mode 100644 index 0000000..019c3da --- /dev/null +++ b/tools/spasm/error.c @@ -0,0 +1,58 @@ +#include "spasm.h" + +static void show_line(void) +{ + printf("%s\n", curLine); + printf("^^^^^^^^^^^^^^\n"); +} + +void instruction_error(char *format, ...) +{ + va_list ap; + + va_start(ap, format); + + printf("Line %d: Error(%s) - ", line_number, curIns); + vprintf(format, ap); + printf("\n"); + show_line(); + + va_end(ap); + + exit(EXIT_FAILURE); +} + +void instruction_warning(char *format, ...) +{ + if(curPass <= 0) + return; + + va_list ap; + + va_start(ap, format); + + printf("Line %d: Warning (%s) - ", line_number, curIns); + vprintf(format, ap); + printf("\n"); + show_line(); + + va_end(ap); +} + +void assembler_error(char *format, ...) +{ + va_list ap; + + va_start(ap, format); + + printf("Line %d, assembler error: ", line_number); + vprintf(format, ap); + printf("\n"); + show_line(); + + va_end(ap); + + exit(EXIT_FAILURE); +} + + \ No newline at end of file -- cgit v1.2.3