Command line usage
The assembler requires exactly two arguments:Path to the assembly source file (.asm)
Path where the assembled binary will be written
Input format
Assembly source files use a line-based format with support for labels, instructions, and directives.Labels
Labels are identifiers followed by a comma:Instructions
Standard Intel 4004 mnemonics are supported. Instructions can take various argument types:Comments
Comments begin with/ and continue to end of line:
Number formats
The assembler supports multiple number literal formats:Character literals
Character literals support escape sequences:'\n'- Newline'\t'- Tab'\a'- Bell (0x07)'\d'- Delete (0x7F)'\\'- Backslash'\''- Single quote
Expressions
The assembler supports arithmetic expressions with operators:Directives
Origin directive
Set the assembly address:Equate directive
Define named constants:Extended syntax
The assembler provides high-level syntax that expands into multiple instructions.Arrow operator (->)
Load values into registers:LDM/LD and XCH instructions.
Use underscore
_ as a placeholder to skip destination registers:Add-assign operator (+=)
Add values to registers:CLC, LDM/LD, ADD, and XCH instructions.
Subtract-assign operator (-=)
Subtract values from registers:CLC, LDM/LD, SUB, XCH, and CMC instructions (except last CMC).
Macros
CALL macro
Implements a subroutine call by pushing the return address:LJCN macro
Long conditional jump (conditional jump to any address):Z?, NZ?, C?, NC?
Expands to a conditional jump over an unconditional jump.
Condition codes
Condition arguments use the? suffix:
Z?- Zero (0b0100)NZ?- Not zero (0b1100)C?- Carry (0b0010)NC?- Not carry (0b1010)
Error handling
The assembler validates:- Type mismatches between arguments and instruction requirements
- Label redefinitions
- 8-bit jumps across page boundaries
- Expression overflow
- Invalid mnemonics and conditions