Easing the way to compare code generated by cc65, 6502-gcc, vbcc, and KickC.
This repository contains scripts to:
- Compile the same source with various 6502 compilers,
- Show the code generated,
- Emulate generated binaries,
- Show performance information.
- You will need an up and running installation of:
- cc65: mandatory, benchmarks for all compilers use CA65 assembler
- Python: highly recomended, automation scripts are written in Python
- gcc or clang: to build the emulator that run banchmarks
- If you want to benchmark extra emulators, you will need them ready to compile some source:
- 6502-gcc: clone and compile it from there: https://github.com/itszor/gcc-6502-bits
- vbcc
The emulator is necessary to run benchmarks. It is not a NES/C64/AppleII/... emulator, it has its own expectations about memory layout.
$ cd emulator/ $ g++ -Imos6502 emulator.cpp mos6502/mos6502.cpp -o emulator
You should now have an executable named emulator
in the emulator/
folder.
Automation scripts heavily rely on environment variables to find compilers.
Note: you can skip any *_BIN
if you have the binary in your PATH
Always needed:
$ export CA65_BIN=/somewhere/cc65/bin/ca65 $ export LD65_BIN=/somewhere/cc65/bin/ld65
Needed for benching cc65:
$ export C65_BIN=/somewhere/cc65/bin/cc65 $ export CC65_LIB=/somewhere/cc65/lib
Needed for benching vbcc:
$ export VBCC=/somewhere/vbcc6502/vbcc6502_linux/vbcc $ export VBCC_BIN=/somewhere/vbcc6502/vbcc6502_linux/vbcc/bin/vc
Needed for benching 6502-gcc:
$ export GCC6502_BIN=/somewhere/gcc-6502-bits/prefix/bin/6502-gcc
Needed for benching KickC:
$ export KICKC_BIN=/somewhere/kickc/bin/kickc.sh
Running the unzip
bench with cc65
:
compilers/cc65/bench code_samples/unzip/unzip.c code_samples/unzip/unzip_data.s
This will produce a fat json on standard output. It contains:
- The number of cycles taken by the generated code
- The size of the generated code
- The memory dump after execution
- The generated assembler
You may add --options="-Oirs"
to pass these flags to the compiler.
You may add --verbose
to have compiler commands being print before executing them.
All compilers/*/bench
scripts share the same comand line interface. Feel free to run the same test with different compilers.
- CA65_BIN: path to
ca65
binary (default:ca65
[aka search in PATH])- CC65_BIN: path to
cc65
binary (default:cc65
[aka search in PATH])- LD65_BIN: path to
ld65
binary (default:ld65
[aka search in PATH])- CC65_LIB: path where cc65's standard
*.lib
can be found (default: tries to link without--lib-path
, doomed to fail)- GCC6502_BIN: path to
6502-gcc
binary (default:6502-gcc
[aka search in PATH])- VBCC_BIN: vc binary from VBCC toolchain (default:
vc
[aka search in PATH])- VBCC: shall point to VBCC's root dir for vbcc compilation to work
- KICKC_BIN: path to
kickc.sh
(or equivalent for your platform) (default:kickc.sh
[aka search in PATH])- EMU65: path to the emulator compiled from the
emulator/
dir