summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main.go b/src/main.go
index 7d2185a..fe040c1 100644
--- a/src/main.go
+++ b/src/main.go
@@ -30,6 +30,7 @@ func readfile(path string) []string {
return raw;
}
+var iflabel int;
func compile(raw[]string) {
print(" section .text")
@@ -70,6 +71,15 @@ func compile(raw[]string) {
print(" cmp rsi, rax")
print(" cmove r10, r11")
print(" push r10")
+ case "if":
+ print(" ;; IF")
+ print(" pop r10")
+ print(" cmp r10, 0")
+ fmt.Printf(" je .if%d\n",iflabel)
+
+ case "endif":
+ fmt.Printf(".if%d:\n",iflabel)
+ iflabel++
default:
panic("invalid word")
}