Skip to main content

p65a

Pythonic 6502 Assembler: An experimental alternative to traditional assemblers.

At this point I'm unsure whether it's a useful concept or not, but I quite enjoy writing code this way. Consider the API to be unstable.

See the examples/ directory for examples of code written using this library.

Here's a snippet from examples/bootloader.py, which showcases a few nice features:

[...,
	lbl.CRC_LUT_HI,
		Db([crc16(bytes([i])) >> 8 for i in range(0x100)]),
	lbl.CRC_LUT_LO,
		Db([crc16(bytes([i])) & 0xff for i in range(0x100)]),

	lbl.crc_update, # input: A, clobbers: A, Y
		A <= A ^ zp.crc_hi,
		Y <= A,
		A <= zp.crc_lo,
		A <= A  ^ lbl.CRC_LUT_HI[Y],
		zp.crc_hi <= A,
		A <= lbl.CRC_LUT_LO[Y],
		zp.crc_lo <= A,
		RTS(),
...]

This snippet implements a CRC16 checksum function. The lookup tables are generated automagically by Python list comprehensions. Each "line" of assembly is an expression contained within a Python list. The <= operator is overloaded to express assignment.

It is possible to make forward-references to labels. They are treated as symbolic expressions until the layout of code is known (and thus, their concrete value), and then the machine code can finally be finally emitted.

TODO

  • Make an installable package
  • Put it on pypi
  • Refactor - there's a lot of code in places it shouldn't be
  • Documentation

Release files for p65a 0.0.1

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

Source distribution (sdist)

Source distribution for p65a 0.0.1
File Size Uploaded
p65a-0.0.1.tar.gz 10.1 kB Details

Built distribution (wheel)

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

Total release size: 18.0 kB

Release files / p65a-0.0.1.tar.gz

Download URL p65a-0.0.1.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
883b802b0261e5d75cf11760036aae927f9edbd539a5f118c97d92997cbec060
BLAKE2b-256 checksum
How to use checksums
cea9d6fc1b912e285f6c051e36e93f67baecc4758972f3cc4e2d85c52b3ba921
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.28.0

Release files / p65a-0.0.1-py3-none-any.whl

Download URL p65a-0.0.1-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
63efb45d64edd4fe3a52459e0684a7cb183939a8c2c72a2f523af35de5a86d67
BLAKE2b-256 checksum
How to use checksums
06534a652424e13fb2ab2df9b3f464ba80a96f375b27f55cc6a9024db6aff762
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.28.0

Release history Release notifications | RSS feed

This release

0.0.1 This release

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