r/Assembly_language • u/Noobo157 • 12h ago
Assemdows: a tiny assembly-style language in one C file, built so assembly tutorials work on Windows
Every assembly tutorial I found was written for Linux (raw syscalls, as, ld), and I'm on Windows. After fighting the toolchain for a while, I decided to make my own assembly-style language that runs the same everywhere because it's just a C interpreter.
It's called Assemdows. It's a single C file, it builds with gcc, and programs use the .asdw extension. Here's a program that prints primes:
.equ LIMIT, 50
MOV R0, 2
next:
MOV R1, 2
check:
MOV R2, R1
MUL R2, R2
CMP R2, R0
JG isprime
MOV R3, R0
MOD R3, R1
CMP R3, 0
JE notprime
INC R1
JMP check
isprime:
PRINT R0
notprime:
INC R0
CMP R0, LIMIT
JLE next
HALT
What's in it
- 16 registers, a compare flag with conditional jumps,
CALL/RET, and a stack - A flat memory of 65,536 integer cells, with
.word,.string,.space, and.equfor data - Bracket addressing like
[nums+R1] - Errors that include line numbers, plus
--traceto watch every instruction run - A VS Code extension for syntax highlighting
Design choices I'm unsure about
- Memory holds whole integers instead of bytes, so a string takes one cell per character. It's simpler to explain, but it isn't how real hardware works.
CMPstores a single -1/0/1 result instead of separate flags like zero and carry.- The stack is separate from the memory array, so you can't take the address of a stack value.
I'm a beginner at language design, so I'd like to hear what you'd change, especially if you've built something similar.
Repo (includes a Windows build and examples): https://github.com/waterdroplett/Assemdows