Grevle Posted January 20, 2016 Share Posted January 20, 2016 I had some problems with the inc and dec instrucions. when i had one instance of incrementing a variable (PX) inc px the loop worked and then was trying to use one more variable (P2X) inc p2x. this was in the same loop but that didnt work, i tried many different ways of using both variables but ,still it would now work, So i had to use some other metode that didnt use two insances of the inc command , and that worked right away so this lead me to think that the inc and dec instructions have some limitations, does it have something to do with the accumulator ? Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted January 20, 2016 Share Posted January 20, 2016 (edited) Both instructions affect the N and Z flags only, so likely they upset some other logic in your loop. It would help to see the code in question, of course. Edited January 20, 2016 by flashjazzcat Quote Link to comment Share on other sites More sharing options...
GroovyBee Posted January 20, 2016 Share Posted January 20, 2016 Can you post your code that didn't work? Quote Link to comment Share on other sites More sharing options...
Grevle Posted January 20, 2016 Author Share Posted January 20, 2016 well i had so many tries and diffent versions and test runs so the code all a mess, it also involves returns to the vbi since its a player movement routine. but i i fixed my program using a different metode by using some instances of the dex command. Quote Link to comment Share on other sites More sharing options...
snicklin Posted January 21, 2016 Share Posted January 21, 2016 I had some problems with the inc and dec instrucions. Intermittently so have I. I don't have any code to show at the moment, but if it comes up again, I'll post it. Quote Link to comment Share on other sites More sharing options...
Rybags Posted January 21, 2016 Share Posted January 21, 2016 There can be traps - often it's nice to use BPL in e.g. a loop that clears hardware registers. You might start at $1F counting back to zero. BPL for such loops falls over if your starting value is over $80 to begin with. Quote Link to comment Share on other sites More sharing options...
popmilo Posted January 21, 2016 Share Posted January 21, 2016 Inc and dec don't change C and V flag, so if you use bcc,bcs,bvc and bvs after inc or dec they jump based on some previous operation. Other than that it should be pretty simple. Values go from 0-255, and new value influences Z and N flag. Your error was probably somewhere else and not because of dec or inc. Could it be something with "p2x" variable name ? I'm not sure if such variable name with 'number between letters' is allowed in assembler you're using ? Quote Link to comment Share on other sites More sharing options...
Grevle Posted January 21, 2016 Author Share Posted January 21, 2016 im using Atasm, hmm i think i used number between letter some other places, like the player equates p0x, p1x, p2x, p3x.. player X postionregisters and it seem to work normal. The error probably is somwhere else. the code is getting quite complicated, for me anyway. Quote Link to comment Share on other sites More sharing options...
popmilo Posted January 21, 2016 Share Posted January 21, 2016 No worries, if you get stuck on another bug, just dump your code here somewhere and you'll get it fixed in no time. Plenty of bored coders around here Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted January 21, 2016 Share Posted January 21, 2016 if I remember my mistakes with inc/dec it was always the BPL/BMI thing most of the time... 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.