func getDataJFromUint32(data uint32) (*DataJ, error) {
	bits := bits.FromUint32(data, 32)
	return &DataJ{
		Opcode:  bits.Slice(31, 26),
		Address: bits.Slice(25, 0),
	}, nil
}
func getDataIFromUint32(data uint32) (*DataI, error) {
	bits := bits.FromUint32(data, 32)
	return &DataI{
		Opcode:    bits.Slice(31, 26),
		RegisterD: bits.Slice(25, 21),
		RegisterS: bits.Slice(20, 16),
		Immediate: bits.Slice(15, 0),
	}, nil
}
func getDataRFromUint32(data uint32) (*DataR, error) {
	bits := bits.FromUint32(data, 32)
	return &DataR{
		Opcode:    bits.Slice(31, 26),
		RegisterD: bits.Slice(25, 21),
		RegisterS: bits.Slice(20, 16),
		RegisterT: bits.Slice(15, 11),
		Shamt:     bits.Slice(10, 6),
		Funct:     bits.Slice(5, 0),
	}, nil
}
Beispiel #4
0
func GetOpcodeFromUint32(value uint32) uint8 {
	bits := bits.FromUint32(value, 32)
	return uint8(bits.Slice(31, 26).ToUint32())
}