Page 1 of 1

machine language problems and question

Posted: Fri Jun 23, 2017 1:42 pm
by vicassembly
I have the situation where I am using relative X addressing and want to be more 'generic.' Here is my situation.

I want to write 1 routine that operates on multiple vectors of numbers. For example:

sprite1: .byte 1,2,..,32 (number of bytes)
sprite2: .byte 1,2,..,32
...
spriten: .byte 1,2,..,32

I wrote the routines to use sprite1 when developing it. I do all sorts of activities where I use nomenclature:

LDA SPRITEDATA1+$10,X or LSR SPRITEDATA1+$08,X etc. etc.

This does not lend itself to being reused very easily. Does anyone have ideas how I might make this more generic? I thought about creating vetors:

splo .byte lobyte_sprite1, .. lobyte_spriten
sphi .byte hibyte_sprite1, .. hibyte_spriten

This way I could load those into a v lo/hi zero page variable and access via:

LDA (lovar),Y

This still doesn't quite match the ,X scheme I had before. Thoughts?



--------------------------------------------------

Second question. Should be an easy one.

Are these two equal?

LDY #$00
BEQ @JUMP

LDY #$00
CPY #$00
BEQ @JUMP

I know that using LDA it would be equal.


Thanks.

Jonathan

Re: machine language problems and question

Posted: Fri Jun 23, 2017 2:28 pm
by srowe
vicassembly wrote:Are these two equal?

LDY #$00
BEQ @JUMP

LDY #$00
CPY #$00
BEQ @JUMP

I know that using LDA it would be equal.
Yes, LDY modifies the Z flag so the CPY is not needed.

Re: machine language problems and question

Posted: Sat Jun 24, 2017 1:32 pm
by pixel
My two cents: go for the LDA (vector),Y – I guess the ,X scheme already gave you a terrible mess, didn't it?