I made an interesting mistake that cost me several hours...I hope to save others some pain. I am using several math routines & thus need to use up most of the registers. which are already in use by my program. In order to temporarily allow their use I merely push the contents into the stack & perform my massive calculations & then pop them back to restore them. Since I was pushing & popping R15-R22 & thought I might do this several places, I decided for efficiency to make both a push & pop subroutine that could do the work.
I was careful to keep my sequence mirrored so as to avoid trouble:
pushem: push r15, push r16, push r17...etc ret
popem: pop etc, pop r17, pop r16, pop r15, ret
do massive calculations
looks simple & efficient, right? Well wrong!! My calc went awry & nothing worked well. Of course I spent a good bit messing with the calcs, but my problem was the simple pushing & popping!! Now I realize that you can't push push push then ret, since the return address is buried at the bottom of the stack!! Nor can you go to a routine & just start popping!
So much for efficiency!