clownassembler - The Open Source asm68k (S.N. 68k) Clone

Clownacy

Member
Messages
47
Wait, what, didn't I just release an entire emulator a couple of weeks ago? Where the heck did this come from?

Here's something I've been quietly working on for a while now: for my honours project at university, I've developed a partial clone of asm68k (also known as S.N. 68k) which aims to function as a drop-in replacement for it. Currently it assembles the Sonic 1 Git disassembly and SuperEgg's Sonic 2 Nick Arcade prototype disassembly without any problems. Unfortunately, software which makes use of asm68k's more elaborate features (like Aurora Fields' Z80 macros, vladikcomper's debugger, and radioshadow's Dr. Robotnik Mean Bean Machine disassembly) do not currently assemble, but I do plan to eventually make this assembler support them.

clownassembler!
'clownass' for short. ;‎)

The idea behind this is to alleviate the community's dependency on a dusty old EXE that's a pain to edit and to run on other platforms (such as Linux, especially on non-x86 architectures). Now, I know, that's what switching to AS was meant to do, and that failed, causing fragmentation. So how is this assembler supposed to avoid the same fate? Simple: AS was not compatible with asm68k, meaning that code made for asm68k had to be tediously ported to AS. This was a hurdle which harmed adoption. clownassembler aims to avoid this by working with the exact same assembly code and the exact same build scripts as asm68k. Converting a disassembly to clownassembler is as simple as replacing the S.N. 68k 'asm68k.exe' file with clownassembler's.

Don't believe me? Here's a video:

And here's a video showing clownassembler building the asm68k version of the Sonic 1 Git disassembly on Linux with zero modifications:

Being an open source project written in good old C, Flex, and Bison means that modifying this assembler should be infinitely easier than modifying the closed-source blob of x86 assembly that is asm68k or the sprawling codebase of AS.

As with clownmdemu, portability is a focus of this assembler. As a showcase of this, the Windows builds on GitHub have been compiled with MSVC 12.0 (the one bundled with Visual Studio 6, from 1998). Good luck finding an operating system that this assembler can't run on!

I'd talk more about my goals for this assembler, but I don't want to start making any big promises. For now, I think that it's best to just enjoy clownassembler for what it currently is: a drop-in asm68k replacement for projects that don't make use of asm68k's more exotic features.

Download
Windows Builds (You'll probably want 'clownassembler_asm68k.exe', as that's the one that's compatible with asm68k's interface. The other one has a custom, simpler, interface that is incompatible with it.)
Source Code

Development
Like with clownmdemu, I've been documenting the development of clownassembler on my blog. There are currently four posts, and I'll cross-post any future ones here.
 
Last edited:
Clownacy posted this elsewhere, but there's been 4 updates since this post, with the latest one, v0.4 being done to be compatible with Sonic 1 asm68k's recently added smps2asm support.

Here's the post.

Looks like I haven't been keeping this thread up to date; I never posted the last four updates!

The newest update was to restore compatibility with the Sonic 1 Git disassembly's 'asm68k' branch, which recently gained SMPS2ASM support using some fancy macros which relied on unimplemented features.

v0.2, v0.3, v0.3.1, v0.4
Added Features

  • Added support for nested macros.
  • Added support for macros using their associated label using '\*' (this is needed by MainMemory's MapMacros).
  • The '\@', '\#', and '\$' macro parameters.
  • The OBJ and OBJEND directives.
  • Passing RSRESET a parameter.
  • The ORG directive.
  • The FAIL directive.
  • The DEF directive.
  • The '/e' command line parameter, allowing constants to be defined.
  • The 'label.w' and 'label.l' absolute address syntax.
  • Misused instructions are automatically corrected to the appropriate instruction, instead of producing an error.
  • The '/v' command line parameter, allowing local labels to be included in the symbol file.
  • The 'w+' and 'w-' options, allowing warnings to be enabled and disabled.
  • The '\_' macro parameter specifier.
  • The 'strcmp' function.
Fixes

  • Fixed identifiers being mistaken for registers.
  • Fixed uppercase Z80 hexadecimal numbers not being recognised
  • Fixed integers that are too large being saturated instead of truncated.
  • Fixed random crashes and nonsensical 'symbol undefined' errors (bugged dictionary).
  • Fixed 'else' following 'elseif' being treated as always true.
  • Fixed CNOP sometimes padding to the second-next boundary instead of the first-next.
  • Made RS, RSSET, and RSRESET behave accurately to asm68k.
  • Fixed using constants for INCBIN parameters.
  • Fixed asm68k-style frontend ignoring all options after the first one.
  • Renamed '__RS' to '__rs' to match asm68k.
  • Fixed broken dictionary logic which was causing symbols to be missing from the symbol file.
  • Fixed true 'ELSEIF' directives causing later conditions to be processed incorrectly.
  • RS labels being able to be used before they were defined.
  • Directives beginning with '.' causing a crash.
  • Nested REPT directives conflicting with each other.
  • Macro parameters sometimes not being substituted.
  • Empty strings not being recognised as strings.
 
Back
Top