22

The closest I was able to find on StackOverflow is What are .S files?, in which no answerer addresses why we use .s for assembly. (And .S for preprocessor/macro assembly; and gcc -S to produce assembly...)

(By "we," I mean basically the POSIX ecosystem. I understand that the .s convention isn't universal. But the convention that does exist, must have originated somewhere.)

My wild guesses are:

  • .s for "source," as opposed to .o for "object." Seems to require a timeline where we had 8.3 filesystems before we had high-level languages.

  • .s for aSsembler, because .a was already occupied by Archive.

Anyone got an authoritative answer, or any anecdotal citations to establish a "not after" date?

6
  • 3
    Regarding “not after”, PDP-7 Unix used .s extensions in 1969. Commented Oct 24, 2020 at 19:58
  • 3
    Although that might be post-facto, since the source files were reconstructed from print-outs. V1 Unix definitely used .s extensions, they’re mentioned e.g. in the B manpage. Commented Oct 24, 2020 at 20:44
  • Though not on the as manpage - so more like a compiler intermediate-file convention rather than an assembler-source convention.
    – dave
    Commented Oct 24, 2020 at 21:46
  • 1
    I guess Unix. DEC systems of the 1960s and later were in the habit of using mutticharacter (generally 3, but 2 on 12-bit systems) extensions. Unix tended to brevity in all things.
    – dave
    Commented Oct 24, 2020 at 21:50
  • 2
    IDK, but Unix loved terse names; "ld," "rm," "mv." Single-letter filename extensions are very much in that spirit, and there aren't all that many single letters from which to choose. Commented Oct 27, 2020 at 12:50

2 Answers 2

23

I asked Ken Thompson. The s stands for source, because it was the only source at the time.

4
  • 1
    That does make some sense, considering that .o means an object file.
    – DrSheldon
    Commented Aug 12, 2022 at 2:41
  • 1
    This is a very authoritative answer. :) So does that imply that Unix (or some Thompson-authored precursor) invented the .s convention, and Thompson got to pick the suffix, ab nihilo? (Along with the more obvious .o and .a, I suppose?) It wasn't an existing convention at the time? Commented Aug 14, 2022 at 20:05
  • Did he explain why it was capitalized (file.S)? Or is that a more recent change?
    – Cole Tobin
    Commented Sep 15, 2022 at 16:33
  • 1
    @ColeTobin: Capital .S indicates source files that need to be preprocessed with cpp before assembling; lowercase .s doesn't get preprocessed. Perhaps cf. the capital .C for files preprocessed with cfront? Commented Feb 6, 2023 at 16:01
14

The V1 Unix B manpage uses .s as the extension for intermediate assembly files used during the build. This is the earliest use of .s that I can find, and would correspond to November 1971 at the latest.

There were assemblers on systems with file systems before Unix, but none that I’m aware of used .s. Some like DECsys don’t appear to have extensions; other used extensions referring to the tool used to process files (e.g. .fap).

Unix as was based on PAL-11R, which used the PAL extension (see page 9-2 of the PAL-11R manual, thanks another-dave!).

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .