position_independent_code_vic20

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/

pic_basic_stub

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.

pic_getpc

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

self_modify_basic_stub

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

Licence

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