package arm

import "git.urbach.dev/cli/q/src/cpu"

// LoadRegister loads from memory into a register.
func LoadRegister(destination cpu.Register, base cpu.Register, offset int, length byte) uint32 {
	offset &= 0b1_1111_1111
	common := 1<<22 | uint32(offset)<<12 | uint32(base)<<5 | uint32(destination)

	switch length {
	case 1:
		return 0b00111<<27 | common
	case 2:
		return 0b01111<<27 | common
	case 4:
		return 0b10111<<27 | common
	case 8:
		return 0b11111<<27 | common
	}

	panic("invalid length")
}