Implemented more arm64 instructions
This commit is contained in:
@ -1,26 +1,27 @@
|
||||
package arm
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
|
||||
"git.urbach.dev/cli/q/src/cpu"
|
||||
)
|
||||
|
||||
// MoveRegisterRegister copies a register to another register.
|
||||
func MoveRegisterRegister(destination cpu.Register, source cpu.Register) uint32 {
|
||||
return 0b10101010<<24 | uint32(source)<<16 | 0b11111<<5 | uint32(destination)
|
||||
}
|
||||
|
||||
// MoveRegisterNumber moves an integer into the given register.
|
||||
func MoveRegisterNumber(code []byte, destination cpu.Register, number int) []byte {
|
||||
return MoveZero(code, destination, 0, uint16(number))
|
||||
func MoveRegisterNumber(destination cpu.Register, number int) uint32 {
|
||||
return MoveZero(destination, 0, uint16(number))
|
||||
}
|
||||
|
||||
// MoveKeep moves a 16-bit integer into the given register and keeps all other bits.
|
||||
func MoveKeep(code []byte, destination cpu.Register, halfword int, number uint16) []byte {
|
||||
x := mov(0b11, halfword, number, destination)
|
||||
return binary.LittleEndian.AppendUint32(code, x)
|
||||
func MoveKeep(destination cpu.Register, halfword int, number uint16) uint32 {
|
||||
return mov(0b11, halfword, number, destination)
|
||||
}
|
||||
|
||||
// MoveZero moves a 16-bit integer into the given register and clears all other bits to zero.
|
||||
func MoveZero(code []byte, destination cpu.Register, halfword int, number uint16) []byte {
|
||||
x := mov(0b10, halfword, number, destination)
|
||||
return binary.LittleEndian.AppendUint32(code, x)
|
||||
func MoveZero(destination cpu.Register, halfword int, number uint16) uint32 {
|
||||
return mov(0b10, halfword, number, destination)
|
||||
}
|
||||
|
||||
// mov encodes a generic move instruction.
|
||||
|
Reference in New Issue
Block a user