Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davidbuchanan314/p65a
Pythonic 6502 Assembler: An experimental alternative to traditional assemblers.
https://github.com/davidbuchanan314/p65a
6502 6502-assembler 6502-assembly assembler python3 python310
Last synced: 2 months ago
JSON representation
Pythonic 6502 Assembler: An experimental alternative to traditional assemblers.
- Host: GitHub
- URL: https://github.com/davidbuchanan314/p65a
- Owner: DavidBuchanan314
- License: mit
- Created: 2022-07-11T23:19:18.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-07-12T14:39:25.000Z (over 2 years ago)
- Last Synced: 2024-03-14T16:22:56.399Z (9 months ago)
- Topics: 6502, 6502-assembler, 6502-assembly, assembler, python3, python310
- Language: Python
- Homepage: https://pypi.org/project/p65a/
- Size: 11.7 KB
- Stars: 17
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```python
[...,
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
- Refactor - there's a lot of code in places it shouldn't be
- Documentation