What is the S file format?
A .s file is a plain-text assembly language source file used across Unix, Linux, macOS, and embedded toolchains. It contains human-readable CPU instructions - mnemonics, operands, assembler directives, and labels - that an assembler translates directly into object code.
The .s extension is a Unix C compiler pipeline convention dating to the 1970s. Running gcc -S on a C source file halts compilation after code generation and writes a .s file, letting you inspect or hand-tune the compiler's output before assembling. That file is then passed to as (the GNU assembler) to produce a .o object file ready for linking.
A subtle but important convention separates lowercase .s from uppercase .S: .s files go directly to the assembler, while .S files pass through the C preprocessor first, allowing #include, #define, and #ifdef directives - a distinction kernel and firmware codebases rely on heavily.
Syntax varies by toolchain. GNU as defaults to AT&T syntax on x86; Windows assemblers such as MASM and Intel-style NASM use Intel syntax. The same .s file layout is used regardless of target ISA - x86-64, ARM/AArch64, RISC-V, MIPS, and others - so the extension itself conveys no architecture information.
.s files carry no magic bytes and have the MIME type text/x-asm. Any text editor opens them; editors with assembly syntax highlighting such as VS Code, Vim, and Emacs are preferred for larger files. The closely related .asm extension serves the same purpose on many non-Unix toolchains.
Security & safety
RISK: LOWA .s file is plain text and does nothing on its own - it cannot run until you deliberately assemble and execute it. The risk is the same as any source code you choose to build: assembly can contain instructions that do anything the CPU allows, so only assemble and run .s files from sources you trust, and read unfamiliar assembly before building it. Opening a .s in a text editor to view it is completely safe.
Format details
in a nutshell- S programming language source - Source code for the S statistical language (predecessor of R); rare today, still seen in legacy statistics code.
- Scheme source (uncommon) - Occasionally a Scheme/Lisp source file, though .scm is the usual extension.
Programs that open S files
Technical details
deep spec| File type | Plain-text assembly language source |
| MIME type | text/x-asm (also accepted: text/x-assembly, text/plain) |
| Encoding | ASCII / UTF-8 |
| File signature (magic bytes) | None - plain text with no fixed header; typically begins with a comment (#, ;), a label (ending in :), or a directive such as .text or .global |
| Line structure | Optional label, assembler directive or CPU mnemonic with operands, inline comment - one logical operation per line |
| Case convention | Lowercase .s is assembled directly; uppercase .S is first run through the C preprocessor (supports #include, #define, #ifdef) |
| Compiler emission | gcc -S or clang -S emits a .s file from C/C++ source, halting the build pipeline after code generation and before assembly |
| Supported ISAs | x86-64, ARM/AArch64, RISC-V, MIPS, POWER/PowerPC, AVR, and others - the extension is ISA-neutral |
| Syntax variants | AT&T syntax (GNU as default on x86), Intel syntax (MASM, NASM), ARM Unified Assembly Language (UAL) |
| Common assembler directives | .text, .data, .bss, .global, .section, .align, .byte, .word, .long, .string |
| Toolchains | GNU Binutils (as), LLVM/Clang integrated assembler, Microsoft MASM, NASM, yasm, armasm |
| Build pipeline role | Intermediate text stage between compiler code-generation and object-file creation; assembled by as or equivalent to produce a .o file |
| Preprocessing support | The .S variant (uppercase) is passed through cpp before assembly, enabling conditional compilation and macro expansion inside asm source |
| Typical file size | 1 KB - 500 KB |
| Associated environments | Linux, Unix, macOS, Windows, embedded/bare-metal (microcontrollers, kernel startup code, bootloaders) |
| Released | 1970s (Unix C compiler toolchain convention) |
| Latest version | N/A (no versioned spec; depends on target CPU ISA and assembler) |
| Open standard | Yes · royalty-free |
| Specification | sourceware.org |
S conversions
Community Q&A
asked by usersNo questions yet - be the first to ask about S files.