BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
errtraplib.c File Reference
#include "blitzlib.h"
#include "blitzexec.h"

Functions

void doreadern (void)
void dosettrap (void)
 SetErr ($D201 seterr): install an error handler.
void doclrerr (void)
void dogetsp (void)
 $D203 (getsp, commented out in blitz2.s): the caller's stack pointer.
void doputsp (void)
 $D204 (putsp, commented out in blitz2.s): set the stack pointer.
void dofail (void)
static void codeinit (void)
void errtraplib_codefinit (void)
void newtrap (void)
void data (void)
static ULONG dofail_c (ULONG num)
 ErrFail ($D205 errfail): report the trapped error after all.
static void codefinit_c (void)
static ULONG doreadern_c (void)
 Ern ($D200 ern): the number of the last trapped error.
static void doclrerr_c (void)
 ClrErr ($D202 clrerr): remove the SetErr handler.

Variables

APTR oldtrap
ULONG ertext
ULONG ercode
ULONG erstack
UWORD ernum

Function Documentation

◆ codefinit_c()

void codefinit_c ( void )
static

◆ codeinit()

void codeinit ( void )
static

◆ data()

void data ( void )

◆ doclrerr()

void doclrerr ( void )

◆ doclrerr_c()

void doclrerr_c ( void )
static

ClrErr ($D202 clrerr): remove the SetErr handler.

Runtime errors go to the old TRAP #0 vector again. Keeps all registers.

◆ dofail()

void dofail ( void )

◆ dofail_c()

ULONG dofail_c ( ULONG num)
static

ErrFail ($D205 errfail): report the trapped error after all.

If an error happened (a message was stored by newtrap), the old trap handler is put back (fixed (#1069): the task's, the original put back the CPU's TRAP #0 vector) and the error is given to it with TRAP #0 (the debugger / runtime error handler), which normally ends the program. Keeps d1/a0-a1 (a0 only if there was no error).

Parameters
numd1: passed on in d1 to the trap
Returns
d0: the stored error message, 0 if there was no error

◆ dogetsp()

void dogetsp ( void )

$D203 (getsp, commented out in blitz2.s): the caller's stack pointer.

Assembler (it reads sp): the stack pointer after the return.

Result
d0: the stack pointer (a0 too)

◆ doputsp()

void doputsp ( void )

$D204 (putsp, commented out in blitz2.s): set the stack pointer.

Assembler: sets sp to d0 and returns through the return address taken from the old stack.

  • d0 the new stack pointer

◆ doreadern()

void doreadern ( void )

◆ doreadern_c()

ULONG doreadern_c ( void )
static

Ern ($D200 ern): the number of the last trapped error.

BUG(orig) (#133): newtrap stores d1 of the trap, but no runtime error sets d1, so the value is random.

Returns
d0: the stored word (d1 at the last trap)

◆ dosettrap()

void dosettrap ( void )

SetErr ($D201 seterr): install an error handler.

Assembler (it reads sp): remembers the handler code and the stack pointer of the caller (after the return). A later runtime error (TRAP #0 in user mode) continues at the handler with that stack.

  • d0 the code to jump to on an error

◆ errtraplib_codefinit()

void errtraplib_codefinit ( void )

◆ newtrap()

void newtrap ( void )

Variable Documentation

◆ ercode

ULONG ercode

◆ ernum

UWORD ernum
extern

◆ erstack

ULONG erstack

◆ ertext

ULONG ertext
extern

◆ oldtrap

APTR oldtrap
extern