summaryrefslogtreecommitdiff
path: root/tools/spasm/error.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/spasm/error.c')
-rw-r--r--tools/spasm/error.c58
1 files changed, 58 insertions, 0 deletions
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