+atari2600land Posted June 12, 2020 Share Posted June 12, 2020 So I have a variable named MusicPtr's value stored in y. What I want to do is divide that value by 8 and then call it in y again. ldy MusicPtr lda Notes,y sta AUDF0 ; what do I do here? lda BassNotes,y sta AUDF1 Am I making myself clear? How do I divide numbers in assembly? Quote Link to comment Share on other sites More sharing options...
JetSetIlly Posted June 12, 2020 Share Posted June 12, 2020 Division by eight can done by shifting right three places. Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted June 12, 2020 Author Share Posted June 12, 2020 How can I shift right if 'asr' doesn't work? Quote Link to comment Share on other sites More sharing options...
JetSetIlly Posted June 12, 2020 Share Posted June 12, 2020 4 minutes ago, atari2600land said: How can I shift right if 'asr' doesn't work? LSR is logical shift right. Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted June 12, 2020 Author Share Posted June 12, 2020 The following doesn't work correctly. Channel 1 just mimics the note changing time of Channel 0. ldy MusicPtr lda Notes,y sta AUDF0 ldy MusicPtr lsr lsr lsr sty MusicPtr2 lda BassNotes,y sta AUDF1 Quote Link to comment Share on other sites More sharing options...
JetSetIlly Posted June 12, 2020 Share Posted June 12, 2020 (edited) LSR works on the accumulator register. So you need to copy the Y register to the A register, with TYA, before shifting. (or just load MusicPtr with LDA) Edited June 12, 2020 by JetSetIlly Quote Link to comment Share on other sites More sharing options...
carlsson Posted June 12, 2020 Share Posted June 12, 2020 (edited) Something like this: lda MusicPtr lsr lsr lsr tay lda BassNotes,y sta AUDF1 Edited June 12, 2020 by carlsson 1 Quote Link to comment Share on other sites More sharing options...
+Pat Brady Posted June 12, 2020 Share Posted June 12, 2020 What carlsson said, but if MusicPtr is already in y, then tya would be slightly better than lda MusicPtr. If you have ROM to spare, you could adjust the values in BassNotes instead of dividing the index. Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted June 13, 2020 Author Share Posted June 13, 2020 Got it working. Thanks, guys. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.