comparison 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
comparison
equal deleted inserted replaced
235:aa0056ca7319 236:a58f49a77441
34 34
35 void write_code_raw(asmstate_t *as, FILE *of); 35 void write_code_raw(asmstate_t *as, FILE *of);
36 void write_code_decb(asmstate_t *as, FILE *of); 36 void write_code_decb(asmstate_t *as, FILE *of);
37 void write_code_rawrel(asmstate_t *as, FILE *of); 37 void write_code_rawrel(asmstate_t *as, FILE *of);
38 void write_code_obj(asmstate_t *as, FILE *of); 38 void write_code_obj(asmstate_t *as, FILE *of);
39 void write_code_os9(asmstate_t *as, FILE *of);
39 40
40 // this prevents warnings about not using the return value of fwrite() 41 // this prevents warnings about not using the return value of fwrite()
41 #define writebytes(s, l, c, f) do { int r; r = fwrite((s), (l), (c), (f)); } while (0) 42 #define writebytes(s, l, c, f) do { int r; r = fwrite((s), (l), (c), (f)); } while (0)
42 43
43 void lwasm_output(asmstate_t *as) 44 void lwasm_output(asmstate_t *as)
72 write_code_rawrel(as, of); 73 write_code_rawrel(as, of);
73 break; 74 break;
74 75
75 case OUTPUT_OBJ: 76 case OUTPUT_OBJ:
76 write_code_obj(as, of); 77 write_code_obj(as, of);
78 break;
79
80 case OUTPUT_OS9:
81 write_code_os9(as, of);
77 break; 82 break;
78 83
79 default: 84 default:
80 fprintf(stderr, "BUG: unrecognized output format when generating output file\n"); 85 fprintf(stderr, "BUG: unrecognized output format when generating output file\n");
81 fclose(of); 86 fclose(of);
118 { 123 {
119 lwasm_line_t *cl; 124 lwasm_line_t *cl;
120 125
121 for (cl = as -> lineshead; cl; cl = cl -> next) 126 for (cl = as -> lineshead; cl; cl = cl -> next)
122 { 127 {
128 if (cl -> nocodelen)
129 {
130 int i;
131 for (i = 0; i < cl -> nocodelen; i++)
132 writebytes("\0", 1, 1, of);
133 continue;
134 }
135 writebytes(cl -> bytes, cl -> codelen, 1, of);
136 }
137 }
138
139
140 /*
141 OS9 target also just writes all the bytes in order. No need for anything
142 else.
143 */
144 void write_code_os9(asmstate_t *as, FILE *of)
145 {
146 lwasm_line_t *cl;
147
148 for (cl = as -> lineshead; cl; cl = cl -> next)
149 {
150 if (cl -> inmod == 0)
151 continue;
123 if (cl -> nocodelen) 152 if (cl -> nocodelen)
124 { 153 {
125 int i; 154 int i;
126 for (i = 0; i < cl -> nocodelen; i++) 155 for (i = 0; i < cl -> nocodelen; i++)
127 writebytes("\0", 1, 1, of); 156 writebytes("\0", 1, 1, of);