Fixed comparison with negative numbers on arm64

This commit is contained in:
2025-03-14 11:14:42 +01:00
parent 9726f1d832
commit 9410287605
5 changed files with 40 additions and 23 deletions

View File

@ -4,10 +4,20 @@ import "git.urbach.dev/cli/q/src/cpu"
// SubRegisterNumber subtracts a number from the given register.
func SubRegisterNumber(destination cpu.Register, source cpu.Register, number int) uint32 {
return addRegisterNumber(0b11, 0, destination, source, number)
return subRegisterNumber(destination, source, number, 0)
}
// SubRegisterRegister subtracts a register from a register.
func SubRegisterRegister(destination cpu.Register, source cpu.Register, operand cpu.Register) uint32 {
return addRegisterRegister(0b11, 0, destination, source, operand)
return subRegisterRegister(destination, source, operand, 0)
}
// subRegisterNumber subtracts the register and optionally updates the condition flags based on the result.
func subRegisterNumber(destination cpu.Register, source cpu.Register, number int, flags uint32) uint32 {
return flags<<29 | 0b110100010<<23 | reg2imm(destination, source, number)
}
// subRegisterRegister subtracts the registers and optionally updates the condition flags based on the result.
func subRegisterRegister(destination cpu.Register, source cpu.Register, operand cpu.Register, flags uint32) uint32 {
return flags<<29 | 0b11001011000<<21 | reg3(destination, source, operand)
}