Skip to content

Bwoah-Kimi/C_compile_template

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C Compile Template

This repository contains a template for compiling C code using RISC-V GCC and generating hex files from assembly output. The directory structure and Makefile are designed to handle multiple C source files and allow for flexible compilation options.

Directory Structrue

.
├── Makefile
├── asm2hex.py
├── build
│   ├── test_code.asm
│   ├── test_code.hex
│   └── test_code.o
├── linker.ld
└── src
    └── test_code.c
  • Makefile: The Makefile used to compile the C source files and generate the necessary output files.
  • asm2hex.py: A Python script to convert assembly files to hex files.
  • linker.ld: The linker script used during the compilation process.
  • src/: Directory containing the C source files.
  • build/: Directory where the compiled object files, assembly files, and hex files will be placed.

Usage

Compiling All C Files

To compile all C files in the src directory, simply run:

make

This will compile all .c files in the src directory and place the output files in the build directory.

Compiling a Single C File

To compile a specific C file, pass the SRC_FILE variable when running make:

make single SRC_FILE=test_code.c

This will compile the specified .c file and place the output files in the build directory.

Cleaning Up

To clean up the build directory and remove all generated files, run:

make clean

asm2hex.py

The asm2hex.py script converts assembly files to hex files. It takes two command-line arguments: the input assembly file and the output hex file.

Usage

python asm2hex.py <input_asm_file> <output_hex_file>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 53.5%
  • C 32.5%
  • Makefile 14.0%