This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

How to take High and Low address of a label?

How to take High and Low address of a label?
by on (#198069)
I have a label that points to code

part1:
LDA $65

Let's pretend this instruction is at $BD65

Then, I have an array with High and Low adress.

High: BD CC
Low: 65 64

for example.

However, those address will need to be where code "part1" is for example.

Since position will change, I would need to do something like

High: part1. HighByte
Low: part1. LowByte

is it possible?
Re: How to take High and Low address of a label?
by on (#198070)
Some popular assemblers use < and > as low and high byte operators:
Code:
low:
.byte <part1
.byte <part2
high:
.byte >part1
.byte >part2

I don't know what assembler you're using but if yours doesn't have those it probably has something equivalent.
Re: How to take High and Low address of a label?
by on (#198086)
If you know that there will be 128 elements or fewer in your array, it might save you typing time (whenever you add another address to the array) by doing this:
Code:
lda pointer      ; can be from 0..$7F
asl a
tax
lda labels,x
sta <zp_ptr
lda labels+1,x
sta <zp_ptr+1
.
.
.

labels: .word part1, part2, part3...