Skip to main content

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

Tiny Assembler

PyPI - Version PyPI - License

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tiny_assembler-0.0.2rc1.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tiny_assembler-0.0.2rc1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

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

Hashes for tiny_assembler-0.0.2rc1.tar.gz
Algorithm Hash digest
SHA256 b1175e47a12559c6b498b7eee6fbcfde1fd9b77afc353e61487fc6ce91ca394b
MD5 9f97fe18b51623c19cfc0088dfbb7061
BLAKE2b-256 448052868cfc5aae1078a7f67457b91068c8622a2d6c33913dfb886e38561578

See more details on using hashes here.

File details

Details for the file tiny_assembler-0.0.2rc1-py3-none-any.whl.

File metadata

File hashes

Hashes for tiny_assembler-0.0.2rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 36a263274071e25ad13d254e7cdc8bea748654096659a6cb9838b0bda125b4f1
MD5 1d5f8dcb042f41efd983935f5a913b64
BLAKE2b-256 828e4a0bc51cc6dc84989cb86dd83b53668f052fc3702f92748e543eb6be27c2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page