Skip to content
Examples of Position Independent Code (6502) on the Commodore VIC-20
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Examples of 6502 Position Independent Code on the VIC-20 from the article Position Independent Code (6502) on the Commodore VIC-20. Please see this article for information about how they work.

The programs' 6502 assembly source code, written for the XA assembler is in src/ and the resulting .prg files are in bin/


Position independent code using jump tables and data tables to obtain position independence. This code is prefixed with a Basic stub so that it can be easily loaded and hence an absolute address for a point in the code can be determined by querying the start of tokenized Basic.


As above, but without a basic stub. This code uses a getpc routine to obtain an absolute address for a point in the code. It is assembled for address 4611, which should allow it to work for any memory configuration. However, this address can be changed and the code will still remain position independent. To run it use the following:

LOAD "*",8,1
SYS 4611


This example self-modifies the code by shifting offsets in code by the start of tokenized Basic to modify offsets for absolute addresses.


To the extent possible under law, Lawrence Woodman has waived all copyright and related or neighboring rights to this work.

You can’t perform that action at this time.