From c3699ac6ac6724a83cd224287556ecf8c6907a86 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sat, 17 Aug 2024 15:08:18 +0200 Subject: [PATCH] Added Windows calling convention registers --- src/compiler/Result.go | 3 ++- src/os/windows/Registers.go | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/os/windows/Registers.go diff --git a/src/compiler/Result.go b/src/compiler/Result.go index 5ca790f..3cb48d1 100644 --- a/src/compiler/Result.go +++ b/src/compiler/Result.go @@ -15,6 +15,7 @@ import ( "git.akyoto.dev/cli/q/src/exe/pe" "git.akyoto.dev/cli/q/src/os/linux" "git.akyoto.dev/cli/q/src/os/mac" + "git.akyoto.dev/cli/q/src/os/windows" ) // Result contains all the compiled functions in a build. @@ -72,7 +73,7 @@ func (r *Result) finalize() ([]byte, []byte) { final.Syscall() case "windows": final.RegisterNumber(asm.SUB, x64.RSP, 32+8) - final.RegisterNumber(asm.MOVE, x64.RCX, 1) + final.RegisterNumber(asm.MOVE, windows.X64InputRegisters[0], 1) final.Label(asm.CALL_AT, "ExitProcess") } diff --git a/src/os/windows/Registers.go b/src/os/windows/Registers.go new file mode 100644 index 0000000..ffbbd21 --- /dev/null +++ b/src/os/windows/Registers.go @@ -0,0 +1,36 @@ +package windows + +import ( + "git.akyoto.dev/cli/q/src/arch/arm64" + "git.akyoto.dev/cli/q/src/arch/x64" + "git.akyoto.dev/cli/q/src/cpu" +) + +var ( + X64InputRegisters = []cpu.Register{ + x64.RCX, + x64.RDX, + x64.R8, + x64.R9, + } + + X64OutputRegisters = []cpu.Register{ + x64.RAX, + } + + ARM64InputRegisters = []cpu.Register{ + arm64.X0, + arm64.X1, + arm64.X2, + arm64.X3, + arm64.X4, + arm64.X5, + arm64.X6, + arm64.X7, + } + + ARM64OutputRegisters = []cpu.Register{ + arm64.X0, + arm64.X1, + } +)