Technical discussions about Freescale Microcontrollers: M68HC11. (Freescale Semiconductor is a Subsidiary of Motorola).
|
First things first. You have got to remove any and all JMP instructions at the end of subroutines. If you attempt to do this it may seem to work, but it will leave the stack pointing to garbage. Your symptom of having problems with nested subroutines is a good way to see this: when the inner subroutine exits the stack will no longer be pointing to the return address of the outer when it exits, so you will be exiting to the wring place. Cardinal rule: never leave a subroutine using a JMP. When you have fixed this, try the program again and see what happens. If it is still playing up, you need to made sure the stack has enought space for all the levels of nesting that you are using. Regards, Nigel bal_gill21 wrote: >Hi, >I have a main program that is calling subroutines, however when it >has finished with the subroutine I issue the RTS command. In some of >my program it works absolutly fine and other times it just returns to >a random address. I have then issued a JMP (followed by appropriate >address)at the end of my subroutine to return to the main program and >it works fine. It becomes a problem when a subroutine calls another >subroutine, because then I really need a RTS command. I am using a >development kit for this to single step the code and I just cannot >work out why this is happening. > >thanks > >Bal > > >Yahoo! Groups Links -- Nigel Johnson MCSE, MIEEE VE3ID/G4AJQ If time travel ever will be possible, it already is. Ask me again yesterday [Non-text portions of this message have been removed] |
|
|