diff lwasm/lwasm.c @ 354:60568b123281

Added os9 opcodes and ERROR
author lost@starbug
date Tue, 30 Mar 2010 23:10:01 -0600
parents 4dba8c7e242c
children 0cf4948d53b4
line wrap: on
line diff
--- a/lwasm/lwasm.c	Tue Mar 30 21:48:49 2010 -0600
+++ b/lwasm/lwasm.c	Tue Mar 30 23:10:01 2010 -0600
@@ -129,6 +129,31 @@
 		cl -> outputbl += 8;
 	}
 	cl -> output[cl -> outputl++] = byte & 0xff;
+	
+	if (cl -> inmod)
+	{
+		asmstate_t *as = cl -> as;
+		// update module CRC
+		// this is a direct transliteration from the nitros9 asm source
+		// to C; it can, no doubt, be optimized for 32 bit processing  
+		byte &= 0xff;
+
+		byte ^= (as -> crc)[0];
+		(as -> crc)[0] = (as -> crc)[1];
+		(as -> crc)[1] = (as -> crc)[2];
+		(as -> crc)[1] ^= (byte >> 7);
+		(as -> crc)[2] = (byte << 1); 
+		(as -> crc)[1] ^= (byte >> 2);
+		(as -> crc)[2] ^= (byte << 6);
+		byte ^= (byte << 1);
+		byte ^= (byte << 2);
+		byte ^= (byte << 4);
+		if (byte & 0x80) 
+		{
+			(as -> crc)[0] ^= 0x80;
+		    (as -> crc)[2] ^= 0x21;
+		}
+	}
 }
 
 void lwasm_emitop(line_t *cl, int opc)