Implemented bitwise AND on arm64
This commit is contained in:
21
src/arm/And.go
Normal file
21
src/arm/And.go
Normal file
@ -0,0 +1,21 @@
|
||||
package arm
|
||||
|
||||
import (
|
||||
"git.urbach.dev/cli/q/src/cpu"
|
||||
)
|
||||
|
||||
// AndRegisterNumber performs a bitwise AND using a register and a number.
|
||||
func AndRegisterNumber(destination cpu.Register, source cpu.Register, number int) uint32 {
|
||||
imm13, encodable := encodeLogicalImmediate(uint(number))
|
||||
|
||||
if !encodable {
|
||||
panic("bitwise and operand can't be encoded as a bitmask immediate")
|
||||
}
|
||||
|
||||
return 0b100100100<<23 | uint32(imm13)<<10 | reg2(destination, source)
|
||||
}
|
||||
|
||||
// AndRegisterRegister performs a bitwise AND using two registers.
|
||||
func AndRegisterRegister(destination cpu.Register, source cpu.Register, operand cpu.Register) uint32 {
|
||||
return 0b10001010<<24 | reg3Imm(destination, source, operand, 0)
|
||||
}
|
Reference in New Issue
Block a user