comparison lwasm/lwasm.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 a9a14e6b4bc8
comparison
equal deleted inserted replaced
235:aa0056ca7319 236:a58f49a77441
77 if (as -> outformat == OUTPUT_OBJ && as -> csect -> flags & SECTION_BSS) 77 if (as -> outformat == OUTPUT_OBJ && as -> csect -> flags & SECTION_BSS)
78 { 78 {
79 register_error(as, l, 1, "Output not allowed inside BSS sections"); 79 register_error(as, l, 1, "Output not allowed inside BSS sections");
80 return; 80 return;
81 } 81 }
82
83 if (as -> outformat == OUTPUT_OS9 && as -> inmod == 0)
84 {
85 register_error(as, l, 1, "Output not allowed outside of module in OS9 mode");
86 return;
87 }
88
82 if (as -> passnum == 1) 89 if (as -> passnum == 1)
83 return; 90 return;
84 91
85 92
86 if (l -> codelen >= l -> codesize) 93 if (l -> codelen >= l -> codesize)
88 l -> bytes = realloc(l -> bytes, l -> codesize + 16); 95 l -> bytes = realloc(l -> bytes, l -> codesize + 16);
89 l -> codesize += 16; 96 l -> codesize += 16;
90 } 97 }
91 l -> bytes[l -> codelen] = b & 0xff; 98 l -> bytes[l -> codelen] = b & 0xff;
92 l -> codelen += 1; 99 l -> codelen += 1;
100
101 if (as -> outformat == OUTPUT_OS9 && as -> inmod)
102 {
103 // calc the CRC
104 b &= 0xff;
105
106 b ^= (as -> crc) >> 16;
107 as -> crc <<= 8;
108 as -> crc ^= b << 1;
109 as -> crc ^= b << 6;
110 b ^= b << 1;
111 b ^= b << 2;
112 b ^= b << 4;
113 if (b & 0x80)
114 as -> crc ^= 0x800021;
115 as -> crc &= 0xffffff;
116 }
93 } 117 }
94 118
95 void lwasm_emitop(asmstate_t *as, lwasm_line_t *l, int o) 119 void lwasm_emitop(asmstate_t *as, lwasm_line_t *l, int o)
96 { 120 {
97 if (o >= 0x100) 121 if (o >= 0x100)