TCC’s assembler enables you to write low-level code without requiring an external assembler, maintaining TCC’s self-reliant philosophy.
Overview
TinyCC Assembler is used to handle:.Sfiles: C preprocessed assembler source.sfiles: Raw assembler source (no preprocessing)- Inline assembly: Using the
asmor__asm__keyword in C code
You can deactivate assembler support for a smaller TCC executable. The C compiler does not rely on the assembler.
Assembly syntax
The TCC assembler supports most of the GNU as (gas) syntax with a few differences.Tokens and comments
Identifier restrictions
Identifier restrictions
Identifiers follow C rules:
- Cannot use
.or$in identifiers (unlike gas) - Must start with a letter or underscore
- Can contain letters, numbers, and underscores
Number formats
Expressions
Operators
Unary operators
Unary operators
Binary operators (by precedence)
Binary operators (by precedence)
Highest precedence:Medium precedence:Lowest precedence:
Label arithmetic
All operators accept absolute values except
+ and -. These can add offsets to labels or compute differences between labels in the same section.Labels
Named labels
All labels are considered local by default, except undefined ones.
Numeric labels
Numeric labels can be defined multiple times and referenced withb (backward) or f (forward):
Directives
All directives are preceded by a. character.
Data definition
Alignment and spacing
.align and .balign
.align and .balign
Align to a power-of-two boundary:
.p2align
.p2align
Align using power-of-two exponent:
.skip and .space
.skip and .space
Reserve space:
.fill
.fill
Repeat a pattern:
Section control
Symbol visibility
Advanced directives
.org - Set location counter
.org - Set location counter
.rept and .endr - Repeat block
.rept and .endr - Repeat block
.set - Define symbol
.set - Define symbol
X86 assembly
All x86 opcodes are supported with ATT syntax (source then destination operand order).Syntax differences
Size suffixes
Addressing modes
Inline assembly in C
TCC supports GCC-style inline assembly with full constraint syntax.Basic inline assembly
Extended inline assembly
Constraint examples
TCC generates the assembly code directly without intermediate files and supports GCC 3.x named operands for better readability.
Limitations
Platform support
The assembler is available on:- i386: Full support (Linux and Windows)
- x86_64: Full support (Linux and Windows)
- ARM: Supported
- ARM64: Supported
- RISC-V: Supported