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

@ -48,8 +48,9 @@ func (r *Result) finalize() ([]byte, []byte) {
final.RegisterNumber(asm.MOVE, x64.SyscallInputRegisters[1], 0)
final.Syscall()
case "windows":
final.RegisterNumber(asm.MOVE, x64.RAX, 0)
final.Return()
final.RegisterNumber(asm.SUB, x64.RSP, 32+8)
final.RegisterNumber(asm.MOVE, x64.RCX, 0)
final.Label(asm.CALL_AT, "ExitProcess")
}
// This will place the main function immediately after the entry point
@ -70,8 +71,9 @@ func (r *Result) finalize() ([]byte, []byte) {
final.RegisterNumber(asm.MOVE, x64.SyscallInputRegisters[1], 1)
final.Syscall()
case "windows":
final.RegisterNumber(asm.MOVE, x64.RAX, 1)
final.Return()
final.RegisterNumber(asm.SUB, x64.RSP, 32+8)
final.RegisterNumber(asm.MOVE, x64.RCX, 1)
final.Label(asm.CALL_AT, "ExitProcess")
}
code, data := final.Finalize()