2015年11月11日 星期三

[C] Write a basic compiler for C

1. Download simple compiler from github
git clone https://github.com/Wilfred/babyc.git


2. Please go into the folder of babyc and type make.
Back to the old commit
git reset --hard dffc393f3254468acfbb3539c2e0f8c464b40464

3. Start to test compiler which we made.
# Assemble the file. We explicitly assemble as 32-bit
# to avoid confusion on x86_64 machines.
$ as out.s -o out.o --32

# Link the file, again specifying 32-bit.
$ ld -m elf_i386 -s -o out out.o

# Run it!
$ ./out

# What was the return code?
$ echo $?
2 
# Woohoo!


Reference:

Related Posts:

0 意見:

張貼留言