Tiny Assembly -- a small assembly-like language targeting ARC because apparently writing.. SIMPLE PROGRAMS WASN'T ENOUGH???
TASM (Tiny Assembly) is a small assembly-like programming language written in Rust!
it's designed to provide a simple register-based language that can eventually compile into ARC bytecode for execution
the main idea is for TASM to act as a frontend for ARC:
TASM source
↓
Lexer
↓
Parser
↓
ISA
↓
Emitter
↓
ARC bytecode
↓
ARC
TASM is intended to have its own syntax and instruction set rather than simply exposing ARC's bytecode instructions directly yayaya
currently implemented:
- zero-copy lexer (i, um, needed to get through.. lifetime mess... srsly.....)
- tokenization
- parser
- AST
- register-based operands
- decimal, hexadecimal, binary, and octal numbers
- labels with instruction bodies
- string literals
- source location tracking
- lexer and parser errors
TASM uses registers named r0 through r31.
a small example:
mov r0, 10
mov r1, 0
loop {
add r1, r1, r0
sub r0, r0, 1
jnz loop
}newlines separate instructions, and labels use braces.
indentation is not syntactically significant!!!! (WOOHOO!!! wait, what.)
TASM is processed in several stages.
the lexer converts source code into tokens:
mov r0, 10
↓
Identifier Register Comma Number
the parser then turns those tokens into an AST containing instructions, operands, and labels.
for example:
mov r0, 10
becomes:
Instruction
├── opcode: "mov"
└── operands:
├── Register(0)
└── Number(10)
the AST will eventually be lowered into TASM's instruction set representation, which the emitter can then translate into ARC bytecode !?
i wanted to make an actual programming language with a low-level, assembly-like design while getting more practice with:
- lexing
- parsing
- AST design
- instruction set design
- compiler architecture
- zero-copy Rust
- emitting bytecode
- working with an existing runtime
and since ARC already exists, TASM gets to focus on being a language instead of also having to build its own virtual machine.
THOUGH, i'm really ITCHING to get to Spark already!!!!
TASM is currently in early development
implemented:
- lexer
- parser
- AST
currently being designed:
- TASM instruction set
- ISA representation
- emitter
- ARC integration
- and more
planned features include:
- arithmetic
- comparisons
- control flow
- memory operations
- functions
- more operand types
- ARC bytecode emission
TASM is designed to target ARC, a stack-based bytecode virtual machine written in Rust.
TASM is not intended to be ARC itself. TASM provides the language and instruction set, while ARC provides the runtime that executes the resulting bytecode.
another frontend, Spark, is also intended to use ARC as a runtime.!!!! (I WANT THIS, THIS INSTANT.)
in general:
- Rust
- Cargo
clone the repository:
git clone https://github.com/jayywashere/tasm
cd tasmrun it with:
cargo runSee LICENSE