Example #1
0
File: dasm.go Project: 8l/e8
func makeInst(buf []byte) inst.Inst {
	ret := uint32(buf[0])
	ret |= uint32(buf[1]) << 8
	ret |= uint32(buf[2]) << 16
	ret |= uint32(buf[3]) << 24

	return inst.Inst(ret)
}
Example #2
0
File: vm.go Project: 8l/e8
// Step executes one instruction.
func (vm *VM) Step() {
	vm.sys.Reset()

	pc := vm.core.IncPC()
	u32 := vm.core.ReadU32(pc)
	in := inst.Inst(u32)
	if vm.Log != nil {
		fmt.Fprintf(vm.Log, "%08x: %08x   %v", pc, u32, in)
		if in.Op() != inst.OpJ {
			rs := in.Rs()
			rt := in.Rt()
			rsv := vm.core.ReadReg(rs)
			rtv := vm.core.ReadReg(rt)
			fmt.Fprintf(vm.Log, "  ; $%d=%d(%08x) $%d=%d(%08x)",
				rs, rsv, rsv, rt, rtv, rtv)
		}
		fmt.Fprintf(vm.Log, "\n")
		// vm.Registers.PrintTo(vm.Log)
	}
	inst.Exec(vm.core, in)

	vm.sys.FlushStdout(vm.Stdout)
}
Example #3
0
File: linker.go Project: 8l/leaf
func setImm(i inst.Inst, im uint16) inst.Inst {
	return inst.Inst(uint32(i) | uint32(im))
}