NESDev and Strangulation Records messageboards
Forum Index | FAQ | New User | Login | Search

Previous ThreadView All ThreadsNext Thread*Show in Threaded Mode


SubjectOffsetting from a label  
Posted bypulper
Posted on9/24/04 9:44 PM
From IP132.241.65.97  



Question: If you wanted to offset 0-255 bytes from a label, could you add the offset without worrying about overflowing or rolling over? Example pseudocode:

samplebyte = mylabel location + myoffset

mylabel:
.byte "9 3 8 7 2 8 1 9"

If your offset was 5, would variable samplebyte be guaranteed to contain the value "2"
after you ran the code?
If so, could someone convert the 1st line into assembly for me? I had too many whiskey cokes
last night...

I'm hoping its something like:

lda #low(mylabel)
sta $20
lda #high(mylabel)
sta $21

ldy myoffset
lda [$20],y
sta samplebyte

Seems to make sense to me... any good?

-Pulper


SubjectRe: Offsetting from a label new  
Posted byMemblers
Posted on9/25/04 00:20 AM
From IP68.58.99.218  



Yeah, the code you posted looks like it does what you want. You can index with the Y register to access 0-255 from the label in zeropage easily.

The only way it'll overflow past the table is if your 'myoffset' input value is larger than it should be. A quick way to check could be doing a CPY #maxvalue then branching on the carry flag condition (a greater/less than check).




Previous ThreadView All ThreadsNext Thread*Show in Threaded Mode
Jump to

Memblers' homepage             Contact Me

Forums powered by WWWThreads Demo