25 lines
519 B
Go
25 lines
519 B
Go
package arm
|
|
|
|
import (
|
|
"git.urbach.dev/cli/q/src/cpu"
|
|
)
|
|
|
|
// StoreRegister writes the contents of the register to a memory address.
|
|
func StoreRegister(source cpu.Register, base cpu.Register, offset int, length byte) uint32 {
|
|
offset &= 0b1_1111_1111
|
|
common := uint32(offset)<<12 | uint32(base)<<5 | uint32(source)
|
|
|
|
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")
|
|
}
|