Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ARMv7 Brainfuck JIT compiler and other ASM examples

This projects contains a number of examples written in ARM unified assembly including Brainfuck JIT compiler. All examples are tested on Cubieboard2 (ARM Cortex-A7 board) running Cubian r4 (Debian Wheezy) with GCC 4.7.

Brainfuck JIT compiler

bfjit(sources) is a limited JIT compiler for a subset of Brainfuck programming language. It supports 5 of 8 Brainfuck commands (,, [ and ] are not supported). It currently implements just-in-time compilation only for > command, the same technique can be used for other commands.

ARM machine code instructions for > command are stored in .data section of ELF binary. When this instruction is found in Brainfuck input source code bfjit uses posix_memalign to allocate page-aligned memory and mprotect to allow to write machine code instructions to that chunk of memory and then branch there to execute written instructions.

hello.bf contains a sample Brainfuck program that prints HELLO ASM.

Build and run the sample program:

as bfjit.s -o bfjit.o
gcc bfjit.o
a.out < hello.bf

About

ARMv7 Brainfuck JIT compiler and other ASM examples

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages