Skip to main content

SAP2 assembler

A simple assembler for the SAP2 computer architecture

sap2assembler can be installed using pip

pip install sap2ssembler

To use the package, you will need to have a file containing your assembly code

# test.sap2asm
mov a, b ; this will move this contents of the Accumulator into the B register

You can assemble the code using the SAP2Assembler class

from sap2assembler import SAP2Assembler # import the class

assembler = SAP2Assembler() # create the assembler object

assembler.assemble_from_file("test.sap2asm", hex_output=True, n_bytes=8, row=4, print_output=True) # assemble and print the first 8 bytes in hex in 4 byte rows
0000: 78 00 00 00
0004: 00 00 00 00

By default, it will print the first 256 bytes in binary in 16 byte rows

If you want to save the machine code into a file, you will need to use the file_to_write parameter

from sap2assembler import SAP2Assembler # import the class

assembler = SAP2Assembler() # create the assembler object

assembler.assemble_from_file("test.sap2asm", n_bytes=8, row=4, file_to_write"output.txt") # save the assembled code into output.txt

output.txt

0000: 01111000 00000000 00000000 00000000
0004: 00000000 00000000 00000000 00000000

To use is as a CLI, you can use the sap2assembler command

sap2assembler
type 'sap2assembler -h' for help

To assemble a file, you need to use the -a flag

sap2assembler -a test.sap2asm -o output.txt -b 8 -rw 4 -hd -p

-o will specify the output file -b is the number of bytes either to write into the file or print -rw is the row width -hd will output the data in hex -p will print the data

console

0000: 78 00 00 00
0004: 00 00 00 00

output.txt

0000: 78 00 00 00
0004: 00 00 00 00

Release files for sap2assembler 4.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sap2assembler 4.0.2
File Size Uploaded
sap2assembler-4.0.2.tar.gz 7.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sap2assembler 4.0.2
File Interpreter ABI Platform
sap2assembler-4.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 15.3 kB

Release files / sap2assembler-4.0.2.tar.gz

Download URL sap2assembler-4.0.2.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a29cc0f36350cb89abaa46b5ac157da96f814c8ce4fcf17899c39cda07686a6d
BLAKE2b-256 checksum
How to use checksums
cdadd3c9d4419f87db9a209a0135921c4bdda7a5b7078b017075e3ec16c431c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release files / sap2assembler-4.0.2-py3-none-any.whl

Download URL sap2assembler-4.0.2-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c4ed822bab9bee4ea9411333c85ba149ea759fe336e3fcd88df6698b6d262a0
BLAKE2b-256 checksum
How to use checksums
c2ffef3fc1a63b8eec286a62b788e999b24397855d17f916dd35e32085e7de18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

4.0.2 This release

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.4.3

2 release files

3.4.2

2 release files

3.4.0

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.1.0

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.2.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.4.0

2 release files

0.2.3

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page