HW4

環境建置

Development packages for Ubuntu Linux Ubuntu 14.04 LTS:
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install gcc-4.8-multilib
sudo apt-get install lua5.2 lua-bitop
sudo apt-get install gcc-arm-linux-gnueabihf
sudo apt-get install qemu-user
 
Building
make
RunningThe Interpreter
$./interpreter progs/hello.bf
 
hello world
 
The Compiler
$make run-compiler
 
./compiler-x86 progs/hello.b > hello.s
cc -m32 -o hello-x86 hello.s
x86:  Hello World!
 
./compiler-x64 progs/hello.b > hello.s
cc -o hello-x64 hello.s
x64:  Hello World!
 
./compiler-arm progs/hello.b > hello.s
arm-linux-gnueabihf-gcc -o hello-arm hello.s
arm:  Hello World!
 
The JIT
$make run-jit-x64
$make run-jit-arm
$make bench-jit-x64
 
Executing Brainf*ck benchmark suite. Be patient.
 
progs/awib.b                     GOOD        70.0ms
progs/mandelbrot.b         GOOD        2766.2ms
progs/hanoi.b                   GOOD        7007.9ms
 
 
資料閱讀
BrainFuck
Brainfuck
C
>
++ptr;
<
--ptr;