/* This C language subroutine controls the fast interrupts received by a program. The Run Time Library for the C Language. Alexander Soto DSP Development Tools Engineering Created on 1/4/90 by GAS Updated on 6/94 by AS #include
void (*signalf(int sig, void (*func)(int))) (int); */ #include "lib_glob.h" #include "sig_glob.h" .SEGMENT/CODE Code_Space_Name; .FILE RTL_FILENAME; .EXTERN ___lib_int_table, ___lib_sure_rts; .GLOBAL ___signal020, ___signal020f, ___signal020s; ___signal020f: JUMP (PC, continue) (DB); R12=___lib_faster_int_cntrl; /*Type of dispatcher - fast*/ R1=6; ___signal020s: JUMP (PC, continue) (DB); R12=___lib_super_int_cntrl; /*Type of dispatcher - super*/ R1=6; ___signal020: R12=___lib_int_cntrl; /*Type of dispatcher - regular*/ R1=6; continue: R0=MODE1; put(R0); /*Save initial state */ R1=R1*R4(SSI); /*Get offset of lib_int_table*/ R0=___SIG_FIRST_INTERRUPT; /*lowest interrupt supported*/ COMP(R4,R0); IF LT JUMP (PC, error_return); /*Bad interrupt number!*/ R0=___SIG_LAST_INTERRUPT-1; /*Total number of interrupts*/ COMP(R4,R0), R0=dm_1; IF GT JUMP (PC, error_return); /*Bad interrupt number!*/ R2=___lib_int_table; /*Point to base of table*/ R4=R2+R1, R2=R4; /*Point to slot in table*/ R1=LSHIFT R0 BY R2; /*Place '1' at int number*/ R0=SIG_IGN; /*Test for ignore interrupt*/ COMP(R0,R8), ram_ireg=R4; /*Point to slot */ IF EQ JUMP (PC, ignore_int) (DB); R0=SIG_DFL; /*Test for default operation*/ COMP(R0,R8), R4=R12; /*R4=dispatcher type */ IF EQ JUMP (PC, default_int) (DB); NOP;NOP; /* DEAD CYCLES */ real_func: JUMP (PC, stop_ints_real) (DB); BIT CLR MODE1 0x1000; /* Disable interrupts */ R12=rammem(defl_mask, ram_ireg);/* Read default mask */ stop_ints_real: rammem(next_mask, ram_ireg)=R12;/* Next mask is default */ R12=rammem(defl_func, ram_ireg);/* Read default function*/ rammem(next_func, ram_ireg)=R12;/* Next function is def */ R0=rammem(curr_func, ram_ireg); /* Read prev function */ rammem(curr_func, ram_ireg)=R8; /* Set interrupt handler*/ R12=IMASK; /* Read interrupt mask */ R4=R1 OR R12, rammem(defl_disp, ram_ireg)=R4; /*Set defl disp*/ JUMP (PC, return_address) (DB); /* Return prev. address */ IMASK=R4; /* Set new mask */ BIT SET MODE1 0x1000; /* Re-enable interrupts */ ignore_int: JUMP (PC, stop_ints_ignor) (DB); BIT CLR MODE1 0x1000; /*Disable all interrupts*/ R0=rammem(curr_func, ram_ireg); /*Read previous function*/ stop_ints_ignor:R4=IMASK; /*Read old interrupt mask*/ R1=NOT R1, rammem(curr_func, ram_ireg)=R8; /*Set int hand, invert mask*/ R4=R1 AND R4, R8=rammem(defl_func, ram_ireg); /*Rd defl func addr, dis ints*/ JUMP (PC, return_address) (DB); IMASK=R4; /*Set new mask*/ BIT SET MODE1 0x1000; /*Enable interrupts*/ default_int: JUMP (PC, stop_ints_def) (DB); BIT CLR MODE1 0x1000; /*Disable all interrupts*/ R12=rammem(defl_mask, ram_ireg); /*Read default mask*/ stop_ints_def: R4=IMASK; /*Read old interrupt mask*/ R4=R1 OR R4, rammem(next_mask, ram_ireg)=R12; /*Next mask to defl, ena ints*/ R4=R12 AND R4, R12=rammem(defl_func, ram_ireg); /*Rd defl func, mask w/defl*/ rammem(next_func, ram_ireg)=R12; /*Set next function to default*/ R0=rammem(curr_func, ram_ireg); /*Read previous function*/ rammem(curr_func, ram_ireg)=R12; /*Set interrupt handler to default*/ JUMP (PC, return_address) (DB); IMASK=R4; /*Set new mask*/ BIT SET MODE1 0x1000; /*Enable interrupts*/ return_address: R8=SIG_DFL; /* Default handler address */ R4=___lib_sure_rts; /* We need to check to see if */ JUMP (PC, restore_state) (DB); /* the old handler was default */ COMP(R0,R4), FETCH_RETURN /* (___lib_sure_rts), if so we */ IF EQ R0=PASS R8; /* return SIG_DFL, not ___lib...*/ restore_state: get(R1,1); MODE1=R1; /*Restore initial state */ RETURN (DB); RESTORE_STACK RESTORE_FRAME error_return: JUMP (PC, restore_state) (DB); R0=SIG_ERR; FETCH_RETURN .ENDSEG;