| Crates.io | asmodeus |
| lib.rs | asmodeus |
| version | 0.1.0 |
| created_at | 2025-06-30 19:07:34.204875+00 |
| updated_at | 2025-06-30 19:07:34.204875+00 |
| description | Complete assembler and emulator for Asmodeus architecture |
| homepage | https://github.com/szymonwilczek/asmodeus |
| repository | https://github.com/szymonwilczek/asmodeus |
| max_upload_size | |
| id | 1732239 |
| size | 219,435 |
Modern Assembly Language Inspired by Machine W Architecture
______ __
/\ _ \ /\ \
\ \ \_\ \ ____ ___ ___ ___ \_\ \ __ __ __ ____
\ \ __ \ /',__\ /' __` __`\ / __`\ /'_` \ /'__`\/\ \/\ \ /',__\
\ \ \/\ \/\__, `\/\ \/\ \/\ \/\ \_\ \/\ \_\ \/\ __/\ \ \_\ \/\__, `\
\ \_\ \_\/\____/\ \_\ \_\ \_\ \____/\ \___,_\ \____\\ \____/\/\____/
\/_/\/_/\/___/ \/_/\/_/\/_/\/___/ \/__,_ /\/____/ \/___/ \/___/
Asmodeus is a complete assembly language toolchain inspired by the legendary Machine W architecture. It features a full compiler pipeline from source code to executable machine code, with advanced debugging capabilities and an extensible instruction set.
curl -sSL https://raw.githubusercontent.com/szymonwilczek/asmodeus/main/installers/install.sh | bash
git clone https://github.com/szymonwilczek/asmodeus.git
cd asmodeus
cargo build --release
cp target/release/asmodeus ~/.local/bin/asmod
export PATH="$HOME/.local/bin:$PATH"
git clone https://github.com/szymonwilczek/asmodeus.git
cd asmodeus
cargo build
# Use cargo run -- [args] or ./installers/dev.sh [args] for development
Create hello.asmod:
; Simple hello world program
start:
POB message ; Load message value into accumulator
WYJSCIE ; Output the value
STP ; Stop program
message: RST 42 ; Our "hello world" message (42)
Run it:
asmod run hello.asmod
; Add two numbers
start:
POB first ; Load first number
DOD second ; Add second number
WYJSCIE ; Output result
STP ; Stop
first: RST 25 ; First operand
second: RST 17 ; Second operand
; Calculate (15 * 3) / 5 = 9
start:
POB #15 ; Load immediate value 15
MNO #3 ; Multiply by 3 (extended instruction)
DZI #5 ; Divide by 5 (extended instruction)
WYJSCIE ; Output result (9)
STP
; Run with: asmod run --extended program.asmod
# Run assembly program (default mode)
asmod run program.asmod
asmod program.asmod # Same as above
# Assemble to binary without running
asmod assemble program.asmod -o program.bin
# Disassemble binary back to assembly
asmod disassemble program.bin
# Interactive debugger with breakpoints
asmod debug program.asmod
# Real-time character I/O mode
asmod interactive program.asmod
# Enable extended instruction set
asmod run --extended program.asmod
# Verbose output for debugging
asmod run --verbose --debug program.asmod
-o, --output FILE: Specify output file-v, --verbose: Verbose output during compilation and execution--debug: Enable debug output (tokens, AST, etc.)-e, --extended: Enable extended instruction set (MNO, DZI, MOD)-h, --help: Show help messageAsmodeus emulates the Machine W architecture with:
AK - Accumulator (16-bit)L - Instruction counter (11-bit, 0-2047)AD - Address register (11-bit)KOD - Opcode register (5-bit)WS - Stack pointer (11-bit, grows downward from 2047)R0-R7 - General purpose registers (16-bit each)DOD addr - Add memory[addr] to AKODE addr - Subtract memory[addr] from AKDOD #value - Add immediate value to AKODE #value - Subtract immediate value from AKŁAD addr / LAD addr - Store AK to memory[addr]POB addr - Load memory[addr] to AKPOB #value - Load immediate value to AKSOB addr - Unconditional jump to addrSOM addr - Jump to addr if AK < 0SOZ addr - Jump to addr if AK = 0STP - Stop program executionSDP - Push AK to stackPZS - Pop from stack to AKWEJSCIE / WPR - Read input to AKWYJSCIE / WYJ - Output AK valueDNS - Disable interruptsCZM - Clear interrupt maskMSK - Set interrupt maskPWR - Return from interruptEnable with --extended flag:
MNO addr - Multiply AK by memory[addr]DZI addr - Divide AK by memory[addr]MOD addr - AK = AK % memory[addr]MNO #value - Multiply AK by immediate valueDZI #value - Divide AK by immediate valueMOD #value - AK = AK % immediate valuePOB 100 - Use memory[100]POB #42 - Use literal value 42POB [100] - Use memory[memory[100]]POB R1 - Use register R1 valuePOB [R1] - Use memory[R1]RST value - Reserve memory and initialize with valueRPA - Reserve memory without initialization (0)MAKRO macro_name param1 param2
; macro body
DOD param1
SOB param2
KONM
; Usage
start:
macro_name 100 end_label
; Line comment
// C-style comment
label_name: ; Define label
POB data ; Reference label
SOB label_name
data: RST 42
Asmodeus includes Bugseer, a powerful interactive debugger:
asmod debug program.asmod
s / step - Execute single instructionc / continue - Continue execution until breakpoint or endd / display - Show current machine stateb ADDRESS / breakpoint ADDRESS - Set breakpoint at addressrb ADDRESS - Remove breakpointlb - List all breakpointsm START [END] - Dump memory rangeh / help - Show all commandsq / quit - Exit debugger(bugseer)> b 5 # Set breakpoint at address 5
(bugseer)> c # Continue until breakpoint
(bugseer)> d # Display machine state
(bugseer)> m 0 10 # Show memory 0-10
(bugseer)> s # Step one instruction
The Asmodeus toolchain consists of several interconnected crates:
asmodeus/
├── src/ # Main CLI application
├── lexariel/ # Lexical analyzer (tokenizer)
├── parseid/ # Parser (tokens → AST)
├── hephasm/ # Assembler (AST → machine code)
├── asmachina/ # Virtual machine (Machine W emulator)
├── dismael/ # Disassembler (machine code → assembly)
├── shared/ # Shared types and utilities
├── examples/ # Example programs
│ ├── basic/ # Simple examples
│ ├── arithmetic/ # Math operations
│ ├── extended_set/ # Extended instruction examples
│ ├── io/ # Input/output examples
│ └── errors/ # Error demonstration
└── tests/ # Integration tests
Source Code (.asmod)
↓ [Lexariel]
Tokens
↓ [Parseid]
Abstract Syntax Tree (AST)
↓ [Hephasm]
Machine Code
↓ [Asmachina]
Execution Results
; Calculate 5! = 120
start:
POB one ; result = 1
LAD result
POB n ; counter = 5
LAD counter
loop:
POB counter ; if counter == 0, done
SOZ done
POB result ; result *= counter
MNO counter ; (requires --extended)
LAD result
POB counter ; counter--
ODE one
LAD counter
SOB loop
done:
POB result ; output result
WYJSCIE
STP
n: RST 5
one: RST 1
result: RPA
counter: RPA
; Echo program with real-time I/O
start:
WEJSCIE ; Read character
WYJSCIE ; Echo it back
STP
; Run with: asmod interactive echo.asmod
; Demonstrate stack usage
start:
POB #10 ; Push 10 to stack
SDP
POB #20 ; Push 20 to stack
SDP
PZS ; Pop 20 to AK
WYJSCIE ; Output 20
PZS ; Pop 10 to AK
WYJSCIE ; Output 10
STP
For more examples, checkout examples directory
git clone https://github.com/szymonwilczek/asmodeus.git
cd asmodeus
cargo build --release
# Unit tests
cargo test
# Integration tests
cargo test --test integration
# Test specific crate
cargo test -p lexariel
cargo test -p asmachina
# Use development wrapper
./installers/dev.sh run examples/basic/hello.asmod
# Or use cargo directly
cargo run -- run examples/basic/hello.asmod
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)lexariel/ - Lexical analysis and tokenizationparseid/ - Syntax analysis and AST generationhephasm/ - Assembly and code generationasmachina/ - Virtual machine and executiondismael/ - Disassembly and reverse engineeringshared/ - Common types and utilitiesExtended instructions not working
# Make sure to use --extended flag
asmod run --extended program.asmod
File extension errors
# Use .asmod for source files
asmod run program.asmod
# Use .bin for binary files (warning: binary files should contain valid Asmodeus syntax!)
asmod disassemble program.bin
Division by zero error
# Check for DZI or MOD with zero operand
DZI #0 ; This will cause runtime error
Undefined symbol error
# Make sure all labels are defined
POB undefined_label ; Error: symbol not found
asmod --help # Show all options
asmod debug program.asmod # Use interactive debugger
asmod run --verbose program.asmod # Verbose output
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ for assembly language enthusiasts