A simple compiler for Intel 8085 opcodes.
It takes 8085 assembly code as input and produces the corresponding machine code or raw binary as output.
Designed as an educational project to explore compiler phases like lexing, parsing, code generation, and symbol resolution.
git clone https://github.com/Auth0x78/Compiler85.git
cd Compiler85
mkdir build && cd build
cmake ..
cmake --build .In Debug mode, the compiler is interactive — no command line arguments required.
$> c85
Debug mode: No command line arguments required.
Enter the filepath of the source file:
Enter the filepath of the output file:
Here’s an updated and polished version of your README section:
In Release mode, the compiler is run from the command line with the following syntax:
$> c85 <sourceFile> <outputFile> [options]-
<sourceFile>: Path to the input 8085 assembly (.asm) file. Can be relative or absolute. -
<outputFile>: Path where the compiled machine code will be written. Can be relative or absolute. -
[options](optional flags):Flag Description -rOutput raw binary ( .bin) instead of the default Intel HEX format-dGenerate a human-readable memory dump of the compiled program -h,--helpShow this help message
Each instruction in the Intel 8085 has its own test case .asm file and a golden .dump file.
test_<test_case_name>.asmfile intests/test_input/→ contains the mnemonicexpect_<test_case_name>.dumpfile intests/test_expect/→ contains expected opcode bytes
- Create a
test_<test_case_name>.asmfile intests/test_input/with the mnemonic. - Create the matching
expect_<test_case_name>.dumpfile intests/test_expect/with expected hex bytes. NOTE: Replace test_case_name with the name of the test you want to give to it
test_HLT.asm:
HLTexpect_HLT.dump:
0 <- Expected return code of the binary
0000: 76 <- Expected output/memory dump of the program.
Most instructions are covered. To add new cases, extend the mnemonics tests.
Generate Intel HEX (default):
$> c85 program.asm program.hexGenerate raw binary:
$> c85 program.asm program.bin -rGenerate memory dump for inspection:
$> c85 program.asm program.dump -dNotes:
- If an output file already exists, it will be overwritten.
Example:
c85 examples/hello.asm build/hello.bin -r- Lexer – tokenize assembly source
- Parser – build AST from tokens
- Code Generation – lower AST into 8085 machine code
- Symbol Resolution & Linking – resolve labels, addresses, and forward references
- Object File Generation – outputs raw machine code or raw (hex-format) binary output to file
- Test Case & Output Verification - verify output against known test cases
- Extend Test Cases - check for every possible point of failure of the application