Fixed move with negative numbers on arm64

This commit is contained in:
Eduard Urbach 2025-03-15 20:34:47 +01:00
parent b3b233c6c9
commit d5118148c9
Signed by: eduard
GPG key ID: 49226B848C78F6C8

View file

@ -22,16 +22,17 @@ func MoveRegisterNumber(code []byte, destination cpu.Register, number int) []byt
func MoveRegisterNumberMI(code []byte, destination cpu.Register, number int) []byte { func MoveRegisterNumberMI(code []byte, destination cpu.Register, number int) []byte {
movz := MoveZero(destination, 0, uint16(number)) movz := MoveZero(destination, 0, uint16(number))
code = binary.LittleEndian.AppendUint32(code, movz) code = binary.LittleEndian.AppendUint32(code, movz)
num := uint64(number)
halfword := 1 halfword := 1
for { for {
number >>= 16 num >>= 16
if number == 0 { if num == 0 {
return code return code
} }
movk := MoveKeep(destination, halfword, uint16(number)) movk := MoveKeep(destination, halfword, uint16(num))
code = binary.LittleEndian.AppendUint32(code, movk) code = binary.LittleEndian.AppendUint32(code, movk)
halfword++ halfword++
} }