Implemented position independent addresses for x86
This commit is contained in:
parent
014f161633
commit
0765351891
3 changed files with 68 additions and 13 deletions
13
src/x86/LoadAddress.go
Normal file
13
src/x86/LoadAddress.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
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))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue