A C89 (or ANSI C) compiler written in Haskell.
kern compiles C89 code into AT&T assembly.
kern is not :
- A preprocessor
- An object code generator
- A linker
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"
- Outputs AT&T assembly
- Follows the X86-64 System V ABI
- Writing a C compiler from Nora Sandler
- The ANSI C syntax