Running Assembly Code directly within Godot

Hi Everyone,

Just for a bit of fun, and because I’ve written assembly for most of my working life I thought it’d be fun to try and get assembly code running directly within Godot.

So to that end I’ve written a module with a simple, error checking, tokenising compiler that allows editing and running assembly directly within Godot. At the moment this is merely a proof of concept and I have many more op codes to implement, but I’m far enough along to get a ‘Hello World’ assembly programming running.

Is this going to replace anything, probably not, and you’ll still need Godot signals to handle communication, but it’s a learning exercise and always fun to do something completely nuts and not the norm… :slight_smile:

The first assembly test and screenshot below.

Kindly

Ryn

Assembly Code

;Hello World - Example
.reset

.code

_start:
	lda 0
	sta b
	
mainLoop:
	lda msg, b
	jz end
	out
	lda b
	inc
	sta b
	jp mainLoop

end:
	brk

.data
	.db msg, "Hello, Godot World!"

Godot Interface

extends Control

func _ready() -> void:
	AssemblyEngine.asm_script_value.connect(asm_script_value)

func asm_script_value(value: float) -> void:
	$TextEdit.text += char(int(value))

func _on_button_pressed() -> void:
	$TextEdit.text = ""
	AssemblyEngine.execute_asmscript("helloworld.asm")

func _on_kill_pressed() -> void:
	AssemblyEngine.runable = false


11 Likes

Oh wow!!! This brings back memories! After my time with the Commodore 64, I slowly drifted away from assembly—it just got too wild for me, too fast. But seeing this running inside Godot is something else entirely! There’s something fascinating about bringing such a low-level approach into a modern engine.

I absolutely love this kind of experimentation, even if it’s just for the fun of it. Can’t wait to see where you take it next—keep up the amazing work! :rocket:

2 Likes

Thanks so much.

My first approach was to build a complete programmable retro computer in Godot (see my GitHub), but now I’ve done that I wanted assembly directly in Godot which I could use in any project. :slight_smile:

Kindly

Ryn

2 Likes

I used to think C++ would provide the fastest results.
If this was a supported language for godot… we’d have the quickest engine ever.

3 Likes

Thanks,

At the moment I’m just concentrating on getting it all working, so speed is not my primary focus. I’ve already got some ideas to improve that.

Throughout my career though I’ve learn’t that it’s just as easy to write crappy assembly code as easily as writing crappy code in any language.

Kindly

Ryn

1 Like

Nice work and this is the good nuts. :laughing:

2 Likes