sguimmara / kern

A C compiler written in Haskell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

kern

A C89 (or ANSI C) compiler written in Haskell.

Overview

kern compiles C89 code into AT&T assembly.

kern is not :

  • A preprocessor
  • An object code generator
  • A linker

Usage

To compile a C file to assembly, type

kern input.c

The output assembly is printed to stdout. Redirect it to a file with

kern input.c > output.s

For example :

returnparam.c

int main(int x, int y)
{
    return y;
}

compiles to

    .file   "returnparam.c"
    .globl  main
    .type   main, @function
main:
    pushq   %rbp
    movq    %rsp, %rbp
    movq    %rbp, %rsp
    movl    %esi, %eax
    popq    %rbp
    ret
    .ident  "kern"

Details

Reference

About

A C compiler written in Haskell

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Haskell 99.3%Language:C 0.7%