Implemented bitwise AND on arm64

This commit is contained in:
2025-03-14 17:45:39 +01:00
parent 72272ed9af
commit e123a26a1d
6 changed files with 119 additions and 5 deletions

21
src/arm/And.go Normal file
View 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)
}