Skip to content

sguimmara/kern

Repository files navigation

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

Releases

No releases published

Packages

No packages published