machine language problems and question

Basic and Machine Language

Moderator: Moderators

vicassembly
Vic 20 Devotee
Posts: 218
Joined: Fri Mar 19, 2010 1:40 pm

machine language problems and question

Postby vicassembly » Fri Jun 23, 2017 1:42 pm

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 Afficionado
Posts: 448
Joined: Mon Jun 16, 2014 3:19 pm

Re: machine language problems and question

Postby srowe » Fri Jun 23, 2017 2:28 pm

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 Nerd
Posts: 867
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/pixel/
Location: various
Occupation: Pan–galactic shaman

Re: machine language problems and question

Postby pixel » Sat Jun 24, 2017 1:32 pm

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


Return to “Programming”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests