diff options
author | Suleyman Farajli <suleyman@farajli.net> | 2024-12-24 23:15:23 +0400 |
---|---|---|
committer | Suleyman Farajli <suleyman@farajli.net> | 2024-12-25 10:12:38 +0400 |
commit | e99c6ed40d991b5cb14da758e75259865bd74bb0 (patch) | |
tree | b53450c9e6e6f2b90c755790258f996b854dcfbe /src | |
parent | 2216327f459cf34dbe65c23e1c488ac3474183a5 (diff) |
nested-less `if` implemented
Diffstat (limited to 'src')
-rw-r--r-- | src/main.go | 10 |
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") } |