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

    pip install tiny_assembler

Usage

To assemble example.asm based on isa.json. The output will be written to example.mem.

    python tiny_assembler.py isa.json example.asm

Instruction Set Architecture (ISA)

ISA's are defined in a json file:

	"metadata":{
		"version": "0.0.1"
	},
	"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.1.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.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file tiny_assembler-0.0.1.tar.gz.

File metadata

  • Download URL: tiny_assembler-0.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 effd31ab6174919a660a70c6367084f792d6c316ae19aa74be0ad580da7cd882
MD5 c816be5dea0c564e9466f36c7ff76ea4
BLAKE2b-256 2d8134fb5c2ab831e256d5c531a03f472ba415f85fc113699693010bf2fd9db8

See more details on using hashes here.

File details

Details for the file tiny_assembler-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: tiny_assembler-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for tiny_assembler-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 147c6ac70ae7b515d90b673e9e675baddbef93d7cbbc0e5ae55474a8c1c88df9
MD5 ac23b40053dfd0eb2a73c1feddbfbc89
BLAKE2b-256 728f3b58434ee9ecb346a43b27d2f8f9d5a0ff5647e8548149f1f5da2a0f4f8e

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