• We've made some quality of life improvements to the Trading Post. More info here.

Vibe coding in 68000 assembler for the original 128K/512K Macs

Tobias

6502
Hi everyone,

(this thread is not about the question if we should use AI models or not)

I'd like to share an experiment from the last few weeks.

The setup:
Everything happens on a Raspberry Pi 5. I use Claude Code and let it write classic Mac software in plain 68000 assembler. The target is my own Mac 512K with the 64K ROM and System 3.x, 400K MFS floppies, and every cycle counts. For testing it drives Mini vMac set up as a 512K; on the real machine I use a Floppy Emu.

The tools:
To make this work without a vintage Mac in the build loop, we ended up writing our own toolchain. Both are open source (MIT), with .deb packages and a Homebrew tap:
- mac68k-asm: 68000 assembler, linker and resource compiler in one C binary.
Old MDS projects should also build with it.
https://github.com/bircher988/mac68k-asm
- mac68k-disk: creates and edits MFS/HFS floppy images.
https://github.com/bircher988/mac68k-disk

Tank Duel:
My latest experiment is a four-against-four top-down tank battle for the 512K: scrolling map with rivers, lakes, forests and destructible walls, tanks in 32 directions, four weapons, computer tanks that flank, take cover and drive home to repair, sampled sound and a radar.
I wrote the game design as one prompt. Claude Code planned eight milestones, wrote about 6,200 lines of 68000 assembler (14.7 KB of code) and tested every step itself in the emulator: scripted keyboard and mouse, screenshots it looked at, frame rate measured at real 512K speed - it even recorded the emulator's sound to check the waveform for clicks. Three prompts, a bit under three hours.
The best part: it runs on my real 512K.

Videos:
- Tank Duel, the whole vibe coding session from the first prompt to the game on
the 512K (4 minutes):
- How to set up the toolchain on Linux:

Sorry that the videos are generated - I'm not a YouTuber.
But everything you see is real: the actual Claude Code session and the game running in the emulator. I think it's still interesting to watch.
 
i think you have a chip on your shoulder, but who doesn't these days?
You wrote:
“can you get it to write machine code to bypass high and low level languages?”

The phrase “machine code” normally means exactly what you mean: the binary instruction encoding executed by the processor.

The only possible source of confusion is “bypass high and low level languages.” Someone could interpret that as you asking whether machine code somehow exists outside the concept of programming languages, and that's presumably what prompted the “fundamental misunderstanding” response.


But technically, your question is understandable.
 
good work. can you get it to write machine code to bypass high and low level languages?
Thanks! An LLM is a text generator, so it can also output machine code
written as hex.

So instead of writing:

Code:
    MOVE.W  #10,-(SP)   ; beep for 10 ticks
    _SysBeep
    _ExitToShell        ; back to the Finder

the LLM can write:

Code:
3F3C 000A A9C8 A9F4

and a small script converts the hex digits into bytes. Together with the
resource structure around it (jump table, code resource, resource map - also
written by hand), that is a complete 362-byte application.

So yes, it's possible, but harder: each time you make a change, you
potentially have to recalculate a big part of your code, because you have to
do all the offset calculations yourself. And there is no gain, because
assembler maps 1:1 to machine code.

It's different with C: C doesn't map 1:1 to machine code - the compiler
chooses the instructions, and on a 68000 you can usually do better by hand.
 
Awesome!! I love the preview of this game. It's gonna be very catchy, I assure you.

Are you planning to release the game?

Incredible dynamics for a game that fits on a Macintosh 128K.

Please consider a richer environment, such as a world containing a variety of bigger and more challenging maps and settings.

You could write a version for a Mac Plus with 1MB of RAM!

BTW: Excellent YouTube guide! I was able to set up the entire toolchain on my Intel Mac running Sonoma in just a few minutes. (Unfortunately, Homebrew no longer supports Intel Macs, but Node can easily be installed via MacPorts instead). mac68K-asm and mac68k-dsk are great tools! Kudos.
 
Last edited:
I’d recommend switching your dev environment from Mini vMac to Snow; Snow is designed to be able to provide verbose output, has an integrated debugger, is cycle exact, and throws errors like a real Mac that Mini vMac happily sidesteps.
 
Awesome!! I love the preview of this game. It's gonna be very catchy, I assure you.

Are you planning to release the game?

Incredible dynamics for a game that fits on a Macintosh 128K.

Please consider a richer environment, such as a world containing a variety of bigger and more challenging maps and settings.

You could write a version for a Mac Plus with 1MB of RAM!

BTW: Excellent YouTube guide! I was able to set up the entire toolchain on my Intel Mac running Sonoma in just a few minutes. (Unfortunately, Homebrew no longer supports Intel Macs, but Node can easily be installed via MacPorts instead). mac68K-asm and mac68k-dsk are great tools! Kudos.
This version needs a 512K Mac (essently for the sound effects), but I am about to construct a version for the 128K Mac. ;)
I think I will share the game here soon.
Thanks a lot trying out mac68K-asm and mac68k-dsk ! :)
 
I’d recommend switching your dev environment from Mini vMac to Snow; Snow is designed to be able to provide verbose output, has an integrated debugger, is cycle exact, and throws errors like a real Mac that Mini vMac happily sidesteps.
Thanks a lot, that looks interesting.
 
So here first version for the 512K and the version where should running also on the original 128K Mac.
Unfortunately I don't have a real 128K Mac to test, it works in the 128K emulator. If someone can test on a real machine I would be happy. :P
 

Attachments

Damn, has anyone managed to beat this even once? The difficulty curve is brutal. The 2D graphics and sound are phenomenal. Getting the whole screen to shake on every hit without any noticeable slowdown is a seriously nice touch. I’d love to see a few gameplay tweaks, though. An auto-drive toggle would save us from having to hold down the W or S key almost permanently (if you stand still, you get killed in no time), and the mines desperately need a buff to their destructive power. Right now, I'm also struggling to find a solid tactical advantage for the machine gun. And those black tanks? Their AI commander is ruthless. Do they actually know how to use the terrain for cover? Overall, it's an incredible achievement. If this had dropped in the late '80s, it would have been an instant classic. I've tested it in Mini vMac and Snow. It feels smoother and snappier in Snow. Tomorrow, I will test it on my 512Ke and come back with more feedback.
 
Last edited:
Back
Top