don't click here

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

Discussion in 'Technical Discussion' started by Clownacy, Jul 19, 2022.

  1. Clownacy

    Clownacy

    Tech Member
    1,099
    689
    93
    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: Jul 19, 2022
  2. Brainulator

    Brainulator

    Regular garden-variety member Member
  3. Clownacy

    Clownacy

    Tech Member
    1,099
    689
    93
    Yes, the idea is to eventually be compatible with AS as well as asm68k. Before I get around to that though, I want to flesh out the asm68k support.
     
  4. Hivebrain

    Hivebrain

    Administrator
    3,068
    204
    43
    53.4N, 1.5W
    Github
    Very interesting. asm68k does a thing where it replaces some instructions with equivalent ones. There's one in Sonic 1 and I found a few more in Streets of Rage 2. Presumably this will always use the correct instructions for byte-perfect ROMs?

    Two features of AS that I always wished asm68k had are Z80 support and custom functions. In fact, I might've switched to AS if not for its lack of a filesize function.

    I tried it with my Sonic 1 disassembly (with Z80 macros removed), and it didn't work. Apparently there's an issue with the ptr macro:

    Image1.png
     
  5. Clownacy

    Clownacy

    Tech Member
    1,099
    689
    93
    The errors are caused by 'strcmp' and 'equs' not being supported yet.

    My assembler should produce the correct machine code for each instruction: that one 'exg' instruction in Sonic 1 definitely assembles correctly.
     
  6. Alriightyman

    Alriightyman

    I am back... from the dead! Tech Member
    357
    11
    18
    Somewhere in hot, death Florida
    0101001101101111011011100110100101100011 00000010: 0101001100000011 01000101011001000110100101110100011010010110111101101110
    Oooh This is really great! Is there support for "debugging symbols", if not, planning for it? I've been thinking with MD Studio that bigevilcorporation has hosted on his github account. I'm rewriting it though in wpf because I feel I can do more with it (I hope). But I'd love to add this assembler to it.
     
  7. Clownacy

    Clownacy

    Tech Member
    1,099
    689
    93
    It can generate .sym files if that's what you're referring to. At some point, I want to get the listing files to resemble asm68k's, which would give another way to obtain symbols, but that hasn't been done yet.
     
  8. Alriightyman

    Alriightyman

    I am back... from the dead! Tech Member
    357
    11
    18
    Somewhere in hot, death Florida
    0101001101101111011011100110100101100011 00000010: 0101001100000011 01000101011001000110100101110100011010010110111101101110
    Ah, cool. I'm going to look through your code just to get an idea on how it all works. Any chance you can point me to to the .sym generation?
    As a side note, I looked at your emulator too. I really like how simplistic it is compared to others - so much easier to get around and see what's going on. Not that it matters, but you get my stamp of approval lol
     
  9. Clownacy

    Clownacy

    Tech Member
    1,099
    689
    93
  10. Techokami

    Techokami

    For use only on NTSC Genesis systems Researcher
    1,374
    86
    28
    HoleNet!
    Sonic Worlds Next
    Since I recently migrated away from Windows to Linux, this will be crazy helpful with working on my Sonic 1 project once the missing features get implemented! (I'm using a lot of Aurora Fields' stuff along with vladikcomper's debugger)