Implemented indirect calls

This commit is contained in:
Eduard Urbach 2024-08-16 20:39:04 +02:00
parent bdd5e5a28e
commit 9c6eb45fe9
Signed by: eduard
GPG key ID: 49226B848C78F6C8
4 changed files with 45 additions and 5 deletions

View file

@ -111,6 +111,25 @@ func (a Assembler) Finalize() ([]byte, []byte) {
codePointers = append(codePointers, pointer)
case CALL_AT:
code = x64.CallAtAddress(code, 0x00_00_00_00)
size := 4
// label := x.Data.(*Label)
pointer := &Pointer{
Position: Address(len(code) - size),
OpSize: 2,
Size: uint8(size),
}
pointer.Resolve = func() Address {
destination := Address(0x1038)
distance := destination - (pointer.Position + Address(pointer.Size))
return Address(distance)
}
codePointers = append(codePointers, pointer)
case COMMENT:
continue

View file

@ -29,6 +29,7 @@ const (
// Control flow
CALL
CALL_AT
JE
JNE
JG
@ -54,6 +55,8 @@ func (m Mnemonic) String() string {
return "and"
case CALL:
return "call"
case CALL_AT:
return "call at"
case COMMENT:
return "comment"
case COMPARE: