// based on MathCoproRegister.cs from FoenixIDE
based on MathCoproRegister.cs from FoenixIDE
// based on MathCoproRegister . cs from FoenixIDE
func (g *Gabe) mathCoop(address uint32, val byte) {
	a := address - 0x00_0100
	switch address {
		case 0x00_0100, 0x00_0101,		
		     0x00_0102, 0x00_0103:		
			g.mem[a] = val
			op1    := uint16(g.mem[0x00]) + uint16(g.mem[0x01]) << 8
			op2    := uint16(g.mem[0x02]) + uint16(g.mem[0x03]) << 8
			result := uint32(op1 * op2)
			g.mem[0x04] = byte(result       & 0xff)
			g.mem[0x05] = byte(result >> 8  & 0xff)
			g.mem[0x06] = byte(result >> 16 & 0xff)
			g.mem[0x07] = byte(result >> 24 & 0xff)
		case 0x00_0108, 0x00_0109,		
		     0x00_010A, 0x00_010B:		
			g.mem[a] = val
			op1    := int16(g.mem[0x08]) + int16(g.mem[0x09]) << 8
			op2    := int16(g.mem[0x0a]) + int16(g.mem[0x0b]) << 8
			result := int32(op1 * op2)
			g.mem[0x0c] = byte(result       & 0xff)
			g.mem[0x0d] = byte(result >> 8  & 0xff)
			g.mem[0x0e] = byte(result >> 16 & 0xff)
			g.mem[0x0f] = byte(result >> 24 & 0xff)
		case 0x00_0110, 0x00_0111,		
	 	     0x00_0112, 0x00_0113:		
			g.mem[a] = val
			op1    := uint16(g.mem[0x10]) + uint16(g.mem[0x11]) << 8
			op2    := uint16(g.mem[0x12]) + uint16(g.mem[0x13]) << 8
			var result, remainder uint16
			if (op1 != 0) {
				result = op2 / op1
				remainder = op2 % op1
			}
			g.mem[0x14] = byte(result          & 0xff)
			g.mem[0x15] = byte(result    >> 8  & 0xff)
			g.mem[0x16] = byte(remainder       & 0xff)
			g.mem[0x17] = byte(remainder >> 8  & 0xff)
		case 0x00_0118, 0x00_0119,		
	 	     0x00_011A, 0x00_011B:		
			g.mem[a] = val
			op1    := int16(g.mem[0x18]) + int16(g.mem[0x19]) << 8
			op2    := int16(g.mem[0x1A]) + int16(g.mem[0x1B]) << 8
			var result, remainder int16
			if (op1 != 0) {
				result = op2 / op1
				remainder = op2 % op1
			}
			g.mem[0x1C] = byte(result          & 0xff)
			g.mem[0x1D] = byte(result    >> 8  & 0xff)
			g.mem[0x1E] = byte(remainder       & 0xff)
			g.mem[0x1F] = byte(remainder >> 8  & 0xff)
		case 0x00_0120, 0x00_0121, 0x00_122, 0x00_123,	
		     0x00_0124, 0x00_0125, 0x00_126, 0x00_127:	
			g.mem[a] = val
			op1    := int32(g.mem[0x20])       + 
			          int32(g.mem[0x21]) <<  8 + 
				  int32(g.mem[0x22]) << 16 + 
				  int32(g.mem[0x23]) << 24
			op2    := int32(g.mem[0x24])       + 
			          int32(g.mem[0x25]) << 8  + 
				  int32(g.mem[0x26]) << 16 + 
				  int32(g.mem[0x27]) << 24
			result := int32(op1 + op2)
			g.mem[0x28] = byte(result       & 0xff)
			g.mem[0x29] = byte(result >> 8  & 0xff)
			g.mem[0x2a] = byte(result >> 16 & 0xff) 
			g.mem[0x2b] = byte(result >> 24 & 0xff) 
		default:
			mylog.Logger.Log(fmt.Sprintf("gabe-math: write to addr %6X val %2X is not implemented", address, val))
	}
}
func ( g * Gabe ) mathCoop ( address uint32 , val byte ) { a := address - 0x00_0100 switch address { case 0x00_0100 , 0x00_0101 , 0x00_0102 , 0x00_0103 : g . mem [ a ] = val op1 := uint16 ( g . mem [ 0x00 ] ) + uint16 ( g . mem [ 0x01 ] ) << 8 op2 := uint16 ( g . mem [ 0x02 ] ) + uint16 ( g . mem [ 0x03 ] ) << 8 result := uint32 ( op1 * op2 ) g . mem [ 0x04 ] = byte ( result & 0xff ) g . mem [ 0x05 ] = byte ( result >> 8 & 0xff ) g . mem [ 0x06 ] = byte ( result >> 16 & 0xff ) g . mem [ 0x07 ] = byte ( result >> 24 & 0xff ) case 0x00_0108 , 0x00_0109 , 0x00_010A , 0x00_010B : g . mem [ a ] = val op1 := int16 ( g . mem [ 0x08 ] ) + int16 ( g . mem [ 0x09 ] ) << 8 op2 := int16 ( g . mem [ 0x0a ] ) + int16 ( g . mem [ 0x0b ] ) << 8 result := int32 ( op1 * op2 ) g . mem [ 0x0c ] = byte ( result & 0xff ) g . mem [ 0x0d ] = byte ( result >> 8 & 0xff ) g . mem [ 0x0e ] = byte ( result >> 16 & 0xff ) g . mem [ 0x0f ] = byte ( result >> 24 & 0xff ) case 0x00_0110 , 0x00_0111 , 0x00_0112 , 0x00_0113 : g . mem [ a ] = val op1 := uint16 ( g . mem [ 0x10 ] ) + uint16 ( g . mem [ 0x11 ] ) << 8 op2 := uint16 ( g . mem [ 0x12 ] ) + uint16 ( g . mem [ 0x13 ] ) << 8 var result , remainder uint16 if ( op1 != 0 ) { result = op2 / op1 remainder = op2 % op1 } g . mem [ 0x14 ] = byte ( result & 0xff ) g . mem [ 0x15 ] = byte ( result >> 8 & 0xff ) g . mem [ 0x16 ] = byte ( remainder & 0xff ) g . mem [ 0x17 ] = byte ( remainder >> 8 & 0xff ) case 0x00_0118 , 0x00_0119 , 0x00_011A , 0x00_011B : g . mem [ a ] = val op1 := int16 ( g . mem [ 0x18 ] ) + int16 ( g . mem [ 0x19 ] ) << 8 op2 := int16 ( g . mem [ 0x1A ] ) + int16 ( g . mem [ 0x1B ] ) << 8 var result , remainder int16 if ( op1 != 0 ) { result = op2 / op1 remainder = op2 % op1 } g . mem [ 0x1C ] = byte ( result & 0xff ) g . mem [ 0x1D ] = byte ( result >> 8 & 0xff ) g . mem [ 0x1E ] = byte ( remainder & 0xff ) g . mem [ 0x1F ] = byte ( remainder >> 8 & 0xff ) case 0x00_0120 , 0x00_0121 , 0x00_122 , 0x00_123 , 0x00_0124 , 0x00_0125 , 0x00_126 , 0x00_127 : g . mem [ a ] = val op1 := int32 ( g . mem [ 0x20 ] ) + int32 ( g . mem [ 0x21 ] ) << 8 + int32 ( g . mem [ 0x22 ] ) << 16 + int32 ( g . mem [ 0x23 ] ) << 24 op2 := int32 ( g . mem [ 0x24 ] ) + int32 ( g . mem [ 0x25 ] ) << 8 + int32 ( g . mem [ 0x26 ] ) << 16 + int32 ( g . mem [ 0x27 ] ) << 24 result := int32 ( op1 + op2 ) g . mem [ 0x28 ] = byte ( result & 0xff ) g . mem [ 0x29 ] = byte ( result >> 8 & 0xff ) g . mem [ 0x2a ] = byte ( result >> 16 & 0xff ) g . mem [ 0x2b ] = byte ( result >> 24 & 0xff ) default : mylog . Logger . Log ( fmt . Sprintf ( " " , address , val ) ) } }
based on MathCoproRegister.cs from FoenixIDE
based on MathCoproRegister . cs from FoenixIDE
// UNSIGNED_MULT_A // UNSIGNED_MULT_B // SIGNED_MULT_A // SIGNED_MULT_B // UNSIGNED_DIV_DEM // UNSIGNED_DIV_NUM // SIGNED_DIV_DEM // SIGNED_DIV_NUM // ADDER32_A // ADDER32_B