6502 Assembly: Loading label address into memory/register

Loading label address into memory/register
bauen1(Game Moderator)
July 8, 2016, 11:32 a.m.

Is it by any chance possible to load the lower/higher byte of a label address into a register? ('LDA #< test' doesn't work)

Loading label address into memory/register
kveroneau(Game Creator)
July 8, 2016, 1:38 p.m.

I can look into this. You can currently load the 16-bit address into memory using the DCW statement:

DCW @label

The prepended @ in the label makes it an absolutely label in memory, which the code relocator will update when the binary is loaded. So the label will always point to the correct location within your code.

This was actually recently added, as I am using it to generate the JSR table for the Kernel API.

After placing this in say your .DATA segment in your code, you can load the upper and lower pretty easily:

LDA %ds,Y

Look at the examples which start with ds for examples on how the .DATA segment works.