Question about code order.
ERIC THE GREAT
Posts: 19
I have a question dealing with the order in which code is written. My question is dealing with some code that Peter helped me with on Sunday. He added a subroutine to my program to take a word and break it into an array of bytes. I noticed that when he sent my program back with the new subroutine code, that he changed the order of some of my program elements.·Instead of having ISR code under the·Interuupt 1000 heading, he moved the ISR code and jumped to it. I believe that the subroutine code was in the middle.·My first attempt in typing in the modified code in the original order (Parallax SXB template) would not compile. The compiler stopped recognizing all declarations after the subroutine in the main program code like PLP XXX and all variable names.I have not tried rearranging the code yet like Peter had it. If it is true that order matters, what is the recommended order of things, i.e interrupt code, subroutine code and program code.
Thanks Eric.
[noparse][[/noparse]Eric, I added a subject to your post. Please put a subject in your future posts. Thanks.]
Post Edited By Moderator (Bean (Hitt Consulting)) : 9/9/2008 6:17:27 PM GMT
Thanks Eric.
[noparse][[/noparse]Eric, I added a subject to your post. Please put a subject in your future posts. Thanks.]
Post Edited By Moderator (Bean (Hitt Consulting)) : 9/9/2008 6:17:27 PM GMT
Comments
The INTERRUPT keyword must come before anything that generates code (like SUB declarations). So it is common to just put a GOTO after the interrupt, and put the actual interrupt code further down (after the SUB declarations).
This is because in the SX chip the interrupt code MUST be at address $000.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"A government big enough to give you everything you want, is big enough to take away everything you·have."·· Thomas Jefferson
"It is our choices, Harry, that show what we truly are, far more than our abilities."·Dumbledore from Harry Potter
www.iElectronicDesigns.com
·