Re: A83: Error handlers [83]


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

Re: A83: Error handlers [83]




In accordance with the prophecy, Henk Poley uttered:

> I looked a bit around and I found something in the sdk83pguide.pdf,
> 
> To install a error handler do:
> 
> LD    HL,foobar
> CALL  _pushErrorHandlER
> 
> 6 pushes are made to the stack (SP)
> You may not PUSH nor POP nor CALL after an error-handler is installed...
> 
> ----
> and to deinstall:
> 
> CALL  _popErrorHandleR
> 
> the 6 pushes are removed from the stack (SP)
> ----
> 
> Now, if an error-handler is in place and an error occures, the 6 pushes are
> removed again (SP is restored, the error-handler is deinstalled), and there
> wil be a jump to the lable you pointed at ('foobar' in this example). The
> 'error-code' will be in the accumulator (register A).
> 
> ----
> Has somebody anything to say on this??? Are there any stange things I
> should know?

On the ti-83, you can certainly use push, pop and call after installing an error
handler. You must remove the error handler before popping what you pushed before
installing it, though.

Then, _pushErrorHandlER and _popErrorHandleR (the capital "ER" and "R" indicate
that the assembler Pat used only cared about the first 15 characters of labels)
are buggy, because they are rom page 12 stubs. For instance:

        _pushErrorHandlER:      call actual_routine
                                ret

But if you do a "call _pushErrorHandlER", you push a return address to the
stack. Then the actual_routine pushes stuff to the stack, and then the ret in
rom page 12 will try to pop a return address from the stack. Instead of a return
address, it will get some gibberish that actual_routine pushed.

There is a workaround for this, that I posted to this list some time ago, so I
won't bother posting it again. =)

Linus
---------------------------------------------------------------------------
Maths and alcohol don't mix. Don't drink and derive.




References: