/swift-9cc

C compiler written in Swift.

Primary LanguageSwift

swift-9cc

C compiler written in Swift with reference to https://www.sigbus.info/compilerbook.

Usage

$make run ARG="(5*(7-1)+3)==66/2" -s
Building for debugging...
Build complete! (0.11s)

----
.intel_syntax noprefix
.globl main
main:
  push 5
  push 7
  push 1
  pop rdi
  pop rax
  sub rax, rdi
  push rax
  pop rdi
  pop rax
  imul rax, rdi
  push rax
  push 3
  pop rdi
  pop rax
  add rax, rdi
  push rax
  push 66
  push 2
  pop rdi
  pop rax
  cqo
  idiv rdi
  push rax
  pop rdi
  pop rax
  cmp rax, rdi
  sete al
  movzb rax, al
  push rax
  pop rax
  ret