diff options
Diffstat (limited to 'src/main.go')
-rw-r--r-- | src/main.go | 29 |
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") |