Skip to content
rubberbagPublic

About

Prints Intel-syntax assembly of C files for learning and exploration

Resources

Stars

3 stars

Watchers

1 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C2ASM

C2ASM is a lightweight C program that compiles C source files and prints their assembly output in Intel syntax. It is designed as a learning tool to explore how C code translates into assembly instructions.

This project currently supports GCC and Clang and is ideal for anyone learning C, assembly, or compiler behavior.

Features

  • Detects installed compilers (GCC or Clang).
  • Generates assembly using -S with Intel syntax (-masm=intel).
  • Dynamic compiler selection: prompts user if both GCC and Clang are installed.
  • Watch mode: automatically recompiles when source file changes and shows diff.
  • Focus mode: highlight specific functions or symbols while dimming other lines.
  • Strip mode: removes common assembly noise (.cfi, .file, .ident).
  • Instruction count: shows the number of instructions per function.
  • Save assembly: writes output to .s files instead of only printing to console.

How It Works

  • Detects installed compiler(s) (GCC/Clang).
  • Builds a dynamic compile command for the source file(s).
  • Executes the compiler command, capturing assembly output.
  • Processes output according to user flags (focus, strip, size, save).
  • In watch mode, automatically detects file changes and shows differences in assembly.

Requirements

  • GCC or Clang installed on your system.
  • Terminal environment
  • C compiler capable of generating Intel-syntax assembly (-masm=intel).

Quick Start

1. Compile ASM Explorer

make           # Build the project
make run       # Run ASM Explorer
make clean     # Remove executable and temporary files

2. Run ASM Explorer

./asm_explorer [options] <source_file> -- [compiler flags]

3. Options

Option Description
--help Show usage information
--watch Recompile when source file changes and show diff
--focus <SYM> Highlight a specific function or symbol
--strip Remove common assembly noise (.cfi, .file, .ident)
--size Show instruction count per function
--Sasm Save assembly output to .s file(s)

4. Examples

Compile a single file and print assembly

./asm_explorer dir/file.c

Strip assembly noise

./asm_explorer --strip dir/file.c

Highlight function "foo" and show instruction count

./asm_explorer --focus foo --size dir/file.c

Watch mode with extra compiler flags

./asm_explorer --watch dir/file.c -- -Wall -Wextra -g -Iinclude

Notes & Future Improvements

Designed primarily for learning and exploring C-to-assembly translation.

  • Platform support: Watch mode currently relies on Linux inotify (macOS/Windows support would require kqueue/file-polling adjustments).
  • Planned improvements:
    • Cleaner, more structured assembly output formatting
    • Cross-platform file monitoring
    • Dynamic support for multiple source files
    • Advanced symbol focus and filtering options

Disclaimer

This is an intentionally lightweight, learning-stage CLI tool built to explore C and assembly internals. Some features (such as watch mode and edge-case argument handling) have known platform and input limitations, and output formatting is kept minimal.

Author

BOADU NERISON PHILIP

About

Prints Intel-syntax assembly of C files for learning and exploration

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages