summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSuleyman Farajli <suleyman@farajli.net>2025-01-01 13:14:55 +0400
committerSuleyman Farajli <suleyman@farajli.net>2025-01-01 13:14:55 +0400
commitc5887ca055da4f46f72b5633476a310928477b43 (patch)
treead08cbca630d663466903fa54fb7f9722a88ddfd /src
parent11a18a9d570f9bcfd8d543d0ad8e507bd3257db8 (diff)
`syscall` updated
Diffstat (limited to 'src')
-rw-r--r--src/main.go29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/main.go b/src/main.go
index 19332c9..d82a3ca 100644
--- a/src/main.go
+++ b/src/main.go
@@ -222,7 +222,33 @@ func X86_64map(op Operation) string{
case "number":
return fmt.Sprintf("\tpush %d\n", op.intData)
case "syscall":
- /*TODO: add syscall*/
+ buf := ""
+ switch op.intData {
+ case 7:
+ buf +="\tpop r9\n"
+ fallthrough
+ case 6:
+ buf +="\tpop r8\n"
+ fallthrough
+ case 5:
+ buf += "\tpop r10\n"
+ fallthrough
+ case 4:
+ buf += "\tpop rdx\n"
+ fallthrough
+ case 3:
+ buf += "\tpop rsi\n"
+ fallthrough
+ case 2:
+ buf += "\tpop rdi\n"
+ fallthrough
+ case 1:
+ buf += "\tpop rax\n"
+ }
+
+ buf += "\tsyscall\n"
+ buf += "\tpush rax\n"
+ return buf
}
panic("X86_64map unreachable")
}
@@ -239,7 +265,6 @@ func compileX86_64(ops[] Operation) {
if (ops[i].name == "string") {
strings = append(strings, [2]string{ops[i].strData, ops[i].label})
}
-
}
print(" ;; EXIT")