Skip to main content
Since version 0.9.16, TinyCC integrates its own assembler supporting GNU gas-like syntax. The assembler handles both standalone assembly files and inline assembly within C code.
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:
  • .S files: C preprocessed assembler source
  • .s files: Raw assembler source (no preprocessing)
  • Inline assembly: Using the asm or __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

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

Only 32-bit integer numbers are supported in expressions.

Expressions

Operators

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 with b (backward) or f (forward):
Numeric labels are useful for local jumps within a function without polluting the namespace.

Directives

All directives are preceded by a . character.

Data definition

Alignment and spacing

Align to a power-of-two boundary:
Align using power-of-two exponent:
Reserve space:
Repeat a pattern:

Section control

Symbol visibility

Advanced directives

The .org directive can only move forward and must stay within reasonable bounds (0 to 0x100000).

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

Currently not supported:
  • SSE instructions (MMX opcodes are supported)
  • Intel syntax (only ATT syntax)
  • 64-bit operand sizes in 32-bit mode
  • Some advanced gas directives

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
For cross-platform code, use C with inline assembly only when necessary for performance-critical or hardware-specific operations.