accousticguitar Posted January 14, 2008 Share Posted January 14, 2008 I would like to exclude a few numbers ($00, $30, $C0, and $F0) but this routine doesn't seem to be doing it. Is there an obvious reason why? LDA Run CLC ADC #$20 BEQ Pickups CMP #$30 BEQ Pickups CMP #$C0 BEQ Pickups CMP #$F0 BEQ Pickups JMP Pickups_2 Pickups: CLC ADC #$10 Pickups_2: STA Run Quote Link to comment Share on other sites More sharing options...
Rybags Posted January 14, 2008 Share Posted January 14, 2008 Looks fine to me. Not in decimal mode (SED), are you? Quote Link to comment Share on other sites More sharing options...
accousticguitar Posted January 14, 2008 Author Share Posted January 14, 2008 Nope, not in decimal mode. Quote Link to comment Share on other sites More sharing options...
Cybergoth Posted January 14, 2008 Share Posted January 14, 2008 Well, $F0 + $10 = $00, so this routine will set Run to $00 when it is $D0 on entry. Quote Link to comment Share on other sites More sharing options...
Rybags Posted January 14, 2008 Share Posted January 14, 2008 Is the code written to do what you want it to do though? It's comparing after adding the initial #$20 value. So, effectively, it is doing: A=(A+32) AND 255 IF A=0 OR A=48 OR A=192 OR A=240 THEN A=A+16 RUN=A So, if the initial value in A is $E0, $10, $A0 or $D0 - then A gets $30 added to it. otherwise, it just gets $20 added. Quote Link to comment Share on other sites More sharing options...
accousticguitar Posted January 14, 2008 Author Share Posted January 14, 2008 (edited) Is the code written to do what you want it to do though? It's comparing after adding the initial #$20 value. So, effectively, it is doing: A=(A+32) AND 255 IF A=0 OR A=48 OR A=192 OR A=240 THEN A=A+16 RUN=A So, if the initial value in A is $E0, $10, $A0 or $D0 - then A gets $30 added to it. otherwise, it just gets $20 added. Yes, that is exactly what I want it to do. I don't want any of those 4 numbers to end up in A. Cybergoth, I did notice that $F0 + $10 = $0 so I changed the $10 to a $20 but it made no difference. Would $F0 + $20 = $10? Edited January 14, 2008 by accousticguitar Quote Link to comment Share on other sites More sharing options...
vdub_bobby Posted January 14, 2008 Share Posted January 14, 2008 Is the code written to do what you want it to do though? It's comparing after adding the initial #$20 value. So, effectively, it is doing: A=(A+32) AND 255 IF A=0 OR A=48 OR A=192 OR A=240 THEN A=A+16 RUN=A So, if the initial value in A is $E0, $10, $A0 or $D0 - then A gets $30 added to it. otherwise, it just gets $20 added. Yes, that is exactly what I want it to do. I don't want any of those 4 numbers to end up in A. Cybergoth, I did notice that $F0 + $10 = $0 so I changed the $10 to a $20 but it made no difference. Would $F0 + $20 = $10? Yes, $F0+$20=$10. Here's an idea: change the code like this: LDA Run Pickups CLC ADC #$20 BEQ Pickups CMP #$30 BEQ Pickups CMP #$C0 BEQ Pickups CMP #$F0 BEQ Pickups STA Run Then you know that it should never get through unless it is one of the right numbers. The key change here is that you check the value after you modify it. Still want to watch out for endless loops, though - I don't know if it will fall into one or not. Plus this version takes less code. Quote Link to comment Share on other sites More sharing options...
accousticguitar Posted January 14, 2008 Author Share Posted January 14, 2008 That's some nice code, and it seems to work fine. Thanks! Now I just need to get my timer to work. Maybe I will post that problem in another thread. I might try searching for "timer" first to see if I can find anything. Quote Link to comment Share on other sites More sharing options...
Rybags Posted January 14, 2008 Share Posted January 14, 2008 If your code is falling over, chances are that something else is modifying the value of "Run", since the first example you posted seems to look fine. Or, should I say, something else is probably defined to use the same memory location as "Run". Quote Link to comment Share on other sites More sharing options...
accousticguitar Posted January 14, 2008 Author Share Posted January 14, 2008 That's what I thought, but I searched "F5" which is where Run is mapped to, and it doesn't come up anywhere else in the assembly code. Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted January 14, 2008 Share Posted January 14, 2008 Yes, but if you have subroutines or stack manipulation nested too deep, ram locations will begin to show signs of curruption (the stack builds itself downward). For example, 5 levels of nesting + a PHA would corrupt $F5. Or, an index register could be using a bad value that causes it to store out of the intended range. Search a z26 .log file for stores to $F5 to be sure. Quote Link to comment Share on other sites More sharing options...
accousticguitar Posted January 15, 2008 Author Share Posted January 15, 2008 (edited) Upon further review, I was wrong. It is skipping over the BEQs like they are not even there. It is adding $20 to the accumulator and then storing it in Run without excluding the numbers at all. It does not appear to be different numbers in there like random numbers being put in. It appears to be adding $20 like clockwork and no more than that ever. Edited January 15, 2008 by accousticguitar Quote Link to comment Share on other sites More sharing options...
accousticguitar Posted January 15, 2008 Author Share Posted January 15, 2008 I changed my approach and went for a range of numbers instead. I replaced this: BEQ Pickups CMP #$30 BEQ Pickups CMP #$C0 BEQ Pickups CMP #$F0 BEQ Pickups JMP Pickups_2 With this: CMP #$40 BMI Pickups CMP #$C0 BCS Pickups JMP Pickups_2 and it works!!! 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.