comparison lwasm/os9.c @ 238:a9a14e6b4bc8

Fixed os9 module CRC calculation
author lost
date Sat, 15 Aug 2009 05:26:02 +0000
parents a58f49a77441
children
comparison
equal deleted inserted replaced
237:dca5938a64aa 238:a9a14e6b4bc8
111 l -> codeaddr = 0; 111 l -> codeaddr = 0;
112 l -> addrset = 1; 112 l -> addrset = 1;
113 as -> addr = 0; 113 as -> addr = 0;
114 114
115 // init crc 115 // init crc
116 as -> crc = 0xffffff; 116 as -> crc[0] = 0xff;
117 as -> crc[1] = 0xff;
118 as -> crc[2] = 0xff;
117 as -> inmod = 1; 119 as -> inmod = 1;
118 120
119 // sync bytes 121 // sync bytes
120 lwasm_emit(as, l, 0x87); 122 lwasm_emit(as, l, 0x87);
121 lwasm_emit(as, l, 0xcd); 123 lwasm_emit(as, l, 0xcd);
136 138
137 // header check 139 // header check
138 lwasm_emit(as, l, ~(0x87 ^ 0xCD ^ (modvals[0] >> 8) ^ (modvals[0] & 0xff) 140 lwasm_emit(as, l, ~(0x87 ^ 0xCD ^ (modvals[0] >> 8) ^ (modvals[0] & 0xff)
139 ^ (modvals[1] >> 8) ^ (modvals[1] & 0xff) 141 ^ (modvals[1] >> 8) ^ (modvals[1] & 0xff)
140 ^ modvals[2] ^ modvals[3])); 142 ^ modvals[2] ^ modvals[3]));
141 143
142 // module type specific output 144 // module type specific output
143 // note that these are handled the same for all so 145 // note that these are handled the same for all so
144 // there need not be any special casing 146 // there need not be any special casing
145 147
146 // exec offset or fmgr name offset 148 // exec offset or fmgr name offset
152 lwasm_emit(as, l, modvals[5] & 0xff); 154 lwasm_emit(as, l, modvals[5] & 0xff);
153 } 155 }
154 156
155 OPFUNC(pseudo_emod) 157 OPFUNC(pseudo_emod)
156 { 158 {
157 unsigned long tcrc; 159 unsigned char tcrc[3];
158 160
159 if (as -> outformat != OUTPUT_OS9) 161 if (as -> outformat != OUTPUT_OS9)
160 { 162 {
161 register_error(as, l, 1, "emod directive only valid for OS9 target"); 163 register_error(as, l, 1, "emod directive only valid for OS9 target");
162 return; 164 return;
167 register_error(as, l, 1, "not in a module!"); 169 register_error(as, l, 1, "not in a module!");
168 return; 170 return;
169 } 171 }
170 172
171 // don't mess with CRC! 173 // don't mess with CRC!
172 tcrc = as -> crc; 174 tcrc[0] = as -> crc[0] ^ 0xff;
173 lwasm_emit(as, l, tcrc >> 16); 175 tcrc[1] = as -> crc[1] ^ 0xff;
174 lwasm_emit(as, l, tcrc >> 8); 176 tcrc[2] = as -> crc[2] ^ 0xff;
175 lwasm_emit(as, l, tcrc); 177 lwasm_emit(as, l, tcrc[0]);
178 lwasm_emit(as, l, tcrc[1]);
179 lwasm_emit(as, l, tcrc[2]);
176 as -> inmod = 0; 180 as -> inmod = 0;
177 } 181 }