A basic assembler for educational processors.
Reason this release was yanked:
This is a test release and should not be used.
Project description
Tiny Assembler
A customizable assembler for cores developed in introductory VLSI courses.
This project is licensed under the terms of the MIT license.
Installation
Install with pip
pip install tiny_assembler
Usage
To assemble example.asm based on isa.json. The output will be written to example.mem.
assemble isa.json example.asm
Instruction Set Architecture (ISA)
ISAs are defined in a json file:
"metadata":{
"version": "0.1.0"
},
"properties":{
"INST_WIDTH": 16,
"DATA_WIDTH": 16,
"OPCODE_WIDTH": 4,
"REG_COUNT": 16,
"LABEL_WIDTH": 10,
"IMM_WIDTH": 8
},
"opcodes":{
"ADD" : 0,
"SLL" : 1,
"SLR" : 2,
"NOT" : 3,
"AND" : 4,
"OR" : 5,
"XOR" : 6,
"NOP" : 7,
"JMP" : 8,
"JZ" : 8,
"JNZ" : 8,
"LD" : 10,
"ST" : 11,
"ADDI" : 12,
"SLLI" : 13,
"SLRI" : 14,
"NOTI" : 15
},
"subopcodes":{
"JMP": 0,
"JZ": 1,
"JNZ": 2
},
"grammar":{
"RRR":["ADD", "SLL", "SLR", "AND", "OR", "XOR"],
"RR": ["NOT", "LD", "ST"],
"RI": ["ADDI", "SLL", "SLR", "NOT"],
"SL": ["JMP", "JZ", "JNZ"],
"NON": ["NOP"]
}
}
Assembly File Example
start:
NOP
NOP
ADDI R1, #1 ; Address Incrementer
ADDI R5, #4 ; Upper address limit
read:
LD R3, R4 ; Load Mem[R4] to R3
ADD R4, R4, R1 ; R4 is the loop variable
XOR R6, R5, R4 ; See if we reach the address limit (R4 == R5)
JNZ $read
XOR R4, R4, R4; Clear R4
write:
; First read the content of the destination (Mem[2])
ADDI R2, #2; Address
LD R3, R2 ; Load Mem[R2] to R3
ADD R4, R4, R1; Data to store (incremented by 1 every step
ST R4, R2 ; Store the new data back to Mem[2]
XOR R6, R5, R4 ; See if we reach the end of loop (R4 == R5)
JNZ $write
JMP $start
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tiny_assembler-0.0.2rc1.tar.gz.
File metadata
- Download URL: tiny_assembler-0.0.2rc1.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1175e47a12559c6b498b7eee6fbcfde1fd9b77afc353e61487fc6ce91ca394b
|
|
| MD5 |
9f97fe18b51623c19cfc0088dfbb7061
|
|
| BLAKE2b-256 |
448052868cfc5aae1078a7f67457b91068c8622a2d6c33913dfb886e38561578
|
File details
Details for the file tiny_assembler-0.0.2rc1-py3-none-any.whl.
File metadata
- Download URL: tiny_assembler-0.0.2rc1-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36a263274071e25ad13d254e7cdc8bea748654096659a6cb9838b0bda125b4f1
|
|
| MD5 |
1d5f8dcb042f41efd983935f5a913b64
|
|
| BLAKE2b-256 |
828e4a0bc51cc6dc84989cb86dd83b53668f052fc3702f92748e543eb6be27c2
|