diff lwasm/output.c @ 236:a58f49a77441

Added os9 target, pragma to control whether $ localizes a symbol, and fixed some condition nesting bugs
author lost
date Fri, 14 Aug 2009 03:22:26 +0000
parents bae1e3ecdce1
children f9f01a499525
line wrap: on
line diff
--- a/lwasm/output.c	Fri Jun 12 05:25:41 2009 +0000
+++ b/lwasm/output.c	Fri Aug 14 03:22:26 2009 +0000
@@ -36,6 +36,7 @@
 void write_code_decb(asmstate_t *as, FILE *of);
 void write_code_rawrel(asmstate_t *as, FILE *of);
 void write_code_obj(asmstate_t *as, FILE *of);
+void write_code_os9(asmstate_t *as, FILE *of);
 
 // this prevents warnings about not using the return value of fwrite()
 #define writebytes(s, l, c, f)	do { int r; r = fwrite((s), (l), (c), (f)); } while (0)
@@ -76,6 +77,10 @@
 		write_code_obj(as, of);
 		break;
 
+	case OUTPUT_OS9:
+		write_code_os9(as, of);
+		break;
+
 	default:
 		fprintf(stderr, "BUG: unrecognized output format when generating output file\n");
 		fclose(of);
@@ -131,6 +136,30 @@
 	}
 }
 
+
+/*
+OS9 target also just writes all the bytes in order. No need for anything
+else.
+*/
+void write_code_os9(asmstate_t *as, FILE *of)
+{
+	lwasm_line_t *cl;
+	
+	for (cl = as -> lineshead; cl; cl = cl -> next)
+	{
+		if (cl -> inmod == 0)
+			continue;
+		if (cl -> nocodelen)
+		{
+			int i;
+			for (i = 0; i < cl -> nocodelen; i++)
+				writebytes("\0", 1, 1, of);
+			continue;
+		}
+		writebytes(cl -> bytes, cl -> codelen, 1, of);
+	}
+}
+
 void write_code_decb(asmstate_t *as, FILE *of)
 {
 	long preambloc;