Example #1
0
func handle(conn net.Conn) {
	defer conn.Close()
	mouth := make([]m16arch.Byte, 4)
	hip := make([]byte, 8)
	mouth[0] = 2
	for a, d := range tests {
		mouth[1] = m16arch.Byte(a)
		mouth[2] = m16arch.Byte(d)
		conn.Write(m16arch.To8Byte(mouth))
		conn.Read(hip)
	}
	s := 256
	mouth[0] = 1
	mouth[2] = 0
	for a, d := range tests {
		mouth[1] = m16arch.Byte(a)
		conn.Write(m16arch.To8Byte(mouth))
		conn.Read(hip)
		out := m16arch.From8Byte(hip)
		if out[0] == d {
			s--
		}
	}
	log.Printf("Failed test is %v times.\n", s)
}
Example #2
0
func readMem(addr m16arch.Byte) m16arch.Byte {
	date := []m16arch.Byte{0x1, m16arch.Byte(addr), 0, 0}
	d := m16arch.To8Byte(date)
	memcon.Write(d)
	memcon.Read(d)
	out := m16arch.From8Byte(d)
	return out[0]
}
Example #3
0
func main() {
	memcon = connect(*memplug)
	cpucon = connect(*cpuplug)
	for a, v := range bios {
		date := []m16arch.Byte{0x2, m16arch.Byte(a), m16arch.Byte(v), 0}
		d := m16arch.To8Byte(date)
		memcon.Write(d)
		memcon.Read(d)
	}
	for {
		in := make([]byte, 8)
		cpucon.Read(in)
		input := m16arch.From8Byte(in)
		out := make([]m16arch.Byte, 4)
		switch input[0] {
		case 1:
			out[0] = readMem(input[1])
		}
		cpucon.Write(m16arch.To8Byte(out))
	}
}
Example #4
0
func main() {
	for i := range tests {
		tests[i] = m16arch.Byte(rand.Intn(0xffff))
	}
	ln, err := net.Listen("tcp", ":23550")
	if err != nil {
		log.Fatal(err)
	}
	for {
		conn, err := ln.Accept()
		if err != nil {
			continue
		}
		go handle(conn)
	}
}
Example #5
0
func writeMem(addr, value m16arch.Byte) {
	date := []m16arch.Byte{0x2, m16arch.Byte(addr), m16arch.Byte(value), 0}
	d := m16arch.To8Byte(date)
	memcon.Write(d)
	memcon.Read(d)
}