machine language problems and question

Basic and Machine Language

Moderator: Moderators

Post Reply
vicassembly
Vic 20 Devotee
Posts: 253
Joined: Fri Mar 19, 2010 1:40 pm

machine language problems and question

Post 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
User avatar
srowe
Vic 20 Scientist
Posts: 1325
Joined: Mon Jun 16, 2014 3:19 pm

Re: machine language problems and question

Post 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.
User avatar
pixel
Vic 20 Scientist
Posts: 1329
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: machine language problems and question

Post 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?
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
Post Reply