q/src/x86/LoadAddress.go
Eduard Urbach bac5986425
All checks were successful
/ test (push) Successful in 14s
Added x86 package
2025-06-23 11:45:57 +02:00

13 lines
No EOL
401 B
Go

package x86
import (
"encoding/binary"
"git.urbach.dev/cli/q/src/cpu"
)
// LoadAddress calculates the address with the RIP-relative offset and writes the result to the destination register.
func LoadAddress(code []byte, destination cpu.Register, offset int) []byte {
code = encode(code, AddressMemory, destination, 0b101, 8, 0x8D)
return binary.LittleEndian.AppendUint32(code, uint32(offset))
}