Skip to main content

A simple assembler for the SAP-2 computer architecture.

Project description

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

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

sap2assembler-4.0.2.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

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

sap2assembler-4.0.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file sap2assembler-4.0.2.tar.gz.

File metadata

  • Download URL: sap2assembler-4.0.2.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for sap2assembler-4.0.2.tar.gz
Algorithm Hash digest
SHA256 a29cc0f36350cb89abaa46b5ac157da96f814c8ce4fcf17899c39cda07686a6d
MD5 74e083368dad60bc6230cdccd627f48a
BLAKE2b-256 cdadd3c9d4419f87db9a209a0135921c4bdda7a5b7078b017075e3ec16c431c0

See more details on using hashes here.

File details

Details for the file sap2assembler-4.0.2-py3-none-any.whl.

File metadata

  • Download URL: sap2assembler-4.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for sap2assembler-4.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1c4ed822bab9bee4ea9411333c85ba149ea759fe336e3fcd88df6698b6d262a0
MD5 6f3e96d6608321582d14631bbf46ad83
BLAKE2b-256 c2ffef3fc1a63b8eec286a62b788e999b24397855d17f916dd35e32085e7de18

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