Skip to content

Add assembler for the custom ISA#1

Open
Elwimen wants to merge 2 commits intoDanijel-Korent:mainfrom
Elwimen:add-assembler
Open

Add assembler for the custom ISA#1
Elwimen wants to merge 2 commits intoDanijel-Korent:mainfrom
Elwimen:add-assembler

Conversation

@Elwimen
Copy link
Copy Markdown

@Elwimen Elwimen commented Mar 22, 2026

Summary

  • Adds assembler.py, a two-pass assembler that takes .asm source files and outputs Logisim v2.0 raw hex format ready to load into ROM
  • Adds useless_OS_clean.asm, a clean labelled assembly source for the existing useless_OS.hex (assembles identically byte-for-byte)

Assembler features

  • Labels for jump targets (shell_loop:, cmd_help:, etc.)
  • Comments (;)
  • Number literals: hex (0xff), decimal, character ('A', '\n', ',')
  • Disambiguates all 8 mov encodings from operand types
  • Meaningful error messages with line numbers

Usage

python3 assembler.py source.asm          # outputs source.hex
python3 assembler.py source.asm -o out.hex

This was made quickly by Claude Sonnet 4.6 as a proof of concept. AI building stuff

Elwimen added 2 commits March 22, 2026 01:29
Two-pass assembler that takes .asm source files and outputs Logisim
v2.0 raw hex format. Supports labels, comments, hex/decimal/char
literals (including escape sequences like '\n'). Also adds a clean,
labelled assembly source for useless_OS that assembles identically
to the existing useless_OS.hex.

This was made quickly by Claude Sonnet 4.6 as a proof of concept. AI building stuff
assembler.py:
- String literals: mov out1, "Hello\nWorld" expands to per-char movs
- Numeric labels: disassembler output (0x0:, 0xa:) now assembles cleanly

Makefile:
- make / make all: force-rebuild all *.asm -> *.hex
- make <stem>: assemble <stem>.asm into useless_OS.hex (active ROM)

New sources:
- useless_OS_strings.asm: useless_OS rewritten using string literals
- fake_linux.asm: fake Linux boot + POSIX-like shell (ls, pwd, uname,
  whoami, help, exit); exit uses out2=0xFF as halt signal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant