diff options
author | Suleyman Farajli <suleyman@farajli.net> | 2025-01-02 00:13:34 +0400 |
---|---|---|
committer | Suleyman Farajli <suleyman@farajli.net> | 2025-01-02 00:13:34 +0400 |
commit | 0652ff24200cbf4e06b6a4135351d9add419776a (patch) | |
tree | af8790ed8ea9e32ddd96d33e76a180c5ab81ee79 /src | |
parent | 6d51febae2ae35ebd3960a4ae087e89bd2988c5d (diff) |
parameter order on the stack reversed for syscalls
Diffstat (limited to 'src')
-rw-r--r-- | src/main.go | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/main.go b/src/main.go index 68db099..e4dfbff 100644 --- a/src/main.go +++ b/src/main.go @@ -246,26 +246,42 @@ func X86_64map(op Operation) string{ case "number": return fmt.Sprintf("\tpush %d\n", op.intData) case "syscall": + /* FIXME: make it more consise */ buf := "" switch op.intData { case 7: + buf += "\tpop rax\n" + buf += "\tpop rdi\n" + buf += "\tpop rsi\n" + buf += "\tpop rdx\n" + buf += "\tpop r10\n" + buf +="\tpop r8\n" buf +="\tpop r9\n" - fallthrough case 6: + buf += "\tpop rax\n" + buf += "\tpop rdi\n" + buf += "\tpop rsi\n" + buf += "\tpop rdx\n" + buf += "\tpop r10\n" buf +="\tpop r8\n" - fallthrough case 5: + buf += "\tpop rax\n" + buf += "\tpop rdi\n" + buf += "\tpop rsi\n" + buf += "\tpop rdx\n" buf += "\tpop r10\n" - fallthrough case 4: + buf += "\tpop rax\n" + buf += "\tpop rdi\n" + buf += "\tpop rsi\n" buf += "\tpop rdx\n" - fallthrough case 3: + buf += "\tpop rax\n" + buf += "\tpop rdi\n" buf += "\tpop rsi\n" - fallthrough case 2: + buf += "\tpop rax\n" buf += "\tpop rdi\n" - fallthrough case 1: buf += "\tpop rax\n" } |