Re: A86: Lets Help Me Debug And Optimize


[Prev][Next][Index][Thread]

Re: A86: Lets Help Me Debug And Optimize




This has happened to me before, and it confuses the hell out of me in a
big program with lots of conditionals and branch calls.  Your problem is
the call you make right before initiating the key loop.  The code that
you call does not end with a RET instruction, so its return address is
left on the stack.  Then you jump to the key loop.  When exit is
pressed, it jumps to the line labeled 'exit', and finds a RET there.  So
it pops that return address from before off the stack, which happend to
point to the instruction at the start of the keyloop.  So it goes
through the keyloop again, and you press exit again, and it does another
RET, but this time it exits the program.  If you had arranged your code
differently, it would crash rather than simply quit after two presses of
the key.

Solution:  Since in all instances where you call PutDirectionLeft,
PutDirectionRight, and PutDirectionBoth, the code makes a jump to the
keyloop, you don't need to use CALL.  So wherever you see CALL
PutDirection... , use JP PutDirection...

Cassady Roop

Elliott Back wrote:
> 
>       Here's the code to a small personal project, with a problem- To exit,
> you press exit twice, or some other miscellanious key twice. This is bad. I
> want it to exit with one puss of only the exit key. Also, any other code
> optomizations you can think of (either speed or SIZE) will be greatly
> appreciated.



References: