May 28, 2025

Sun 3/60 -- Boot ROM sources and Sun assembler syntax

You will often hear (and it is true) that there is MIT syntax and Motorola syntax for m68k assembly language. But consider this chunk of code from some old Sun sources that I have found laying around:
    movl    d6,sp@-         | Size of working memory...
    jbsr    _mapmem         | Go map/zap it.
    addql   #4,sp
This looks like perfectly good MIT syntax that the gnu assembler would accept, except for one thing. The gnu assembler expects registers to be prefixed by a % sign, such as %d6 and %sp in the above.

Typing "m68k-linux-gnu-as --help" yields a bunch of help (but not m68k specific options seem to be listed).

The above is a 238 page PDF file, and it has a section describing processor specific options. One option for the m68k version of the assembler is ‘--register-prefix-optional’ and it turns out this is just what we need. If we have variables or function names that match register names, it will no longer be possible to distinguish them, but this seems relatively unlikely, especially in old sun code with an assembler that was unable to do so.

I end up using this:

m68k-linux-gnu-as -m68020 --register-prefix-optional start.S -o start.o