nesdev.com
http://forums.nesdev.com/

How to take High and Low address of a label?
http://forums.nesdev.com/viewtopic.php?f=2&t=16084
Page 1 of 1

Author:  MartsINY [ Mon Jun 12, 2017 5:43 pm ]
Post subject:  How to take High and Low address of a label?

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?

Author:  rainwarrior [ Mon Jun 12, 2017 5:49 pm ]
Post subject:  Re: How to take High and Low address of a label?

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.

Author:  ccovell [ Mon Jun 12, 2017 8:59 pm ]
Post subject:  Re: How to take High and Low address of a label?

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...

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/