Sundown / raom

:racing_car: Tiny arithmetic-only LISP compiler targeting x86.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Raom

The beginnings of a compiler. 🏎️

Currently compiles +, -, *, /, () using LISP syntax.

Developed for macOS. Could run into problems on Linux with _main rather than main, among other things.

Written in C89 apart from an anonymous union (__extension__).

(* 5 (+ 90 10))

Is compiled to

.intel_syntax noprefix
.globl _main
_main:
  push 5
  push 90
  push 10
  pop rdi
  pop rax
  add rax, rdi
  push rax
  pop rdi
  pop rax
  imul rax, rdi
  push rax
  pop rax
  ret

Compiling that with Clang/GCC and running the binary will return 244.

You can check the return value of a program with echo $?.

About

:racing_car: Tiny arithmetic-only LISP compiler targeting x86.

License:MIT License


Languages

Language:C 97.5%Language:Makefile 2.5%