/* This C language subroutine controls the interrupts received by a program. The Run Time Library for the C Language. Alexander Soto DSP Development Tools Engineering Created on 1/19/91 by GAS Updated on 4/19/94 by AS #include
void (*interrupt(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 ___interrupt020, ___interrupt020f, ___interrupt020s; ___interrupt020f: JUMP (PC, continue) (DB); R12=___lib_faster_int_cntrl; /*Type of dispatcher - fast*/ R1=6; /*Each slot requires 6 locations*/ ___interrupt020s: JUMP (PC, continue) (DB); R12=___lib_super_int_cntrl; /*Type of dispatcher - super*/ R1=6; /*Each slot requires 6 locations*/ ___interrupt020: R12=___lib_int_cntrl; /*Type of dispatcher - regular*/ R1=6; /*Each slot requires 6 locations*/ continue: R0=MODE1; put(R0); /*Save init state */ R1=R1*R4 (SSI); /* next mask, next, func, def mask, def*/ R0=___SIG_FIRST_INTERRUPT; /*lowest supported interrupt*/ COMP(R4,R0); /*Read second argument*/ 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, r2=sig*/ R1=LSHIFT R0 BY R2; /*Place '1' at int number*/ R0=SIG_IGN; /*Test for ignore interrupt*/ COMP(R0,R8), ram_ireg=R4; /*Prepare to point to slot*/ IF EQ JUMP (PC, ignore_int) (DB); R0=SIG_DFL; /*Test for default operation*/ COMP(R0,R8); IF EQ JUMP (PC, default_int) (DB); NOP;NOP; /* DEAD CYCLES */ real_func: JUMP (PC, stop_ints_real) (DB); BIT CLR MODE1 0x1000; /*Disable all interrupts*/ R0=0xFFFFFFFF; /*Set mask to all '1's*/ stop_ints_real: R4=IMASK; /*Read old interrupt mask*/ rammem(next_mask, ram_ireg)=R0; /*Set next mask to all '1's*/ rammem(next_func, ram_ireg)=R8; /*Set next function to handler*/ R0=rammem(curr_func, ram_ireg); /*Read old handler*/ rammem(curr_func, ram_ireg)=R8; /*Set interrupt handler*/ R4=R4 OR R1, rammem(defl_disp, ram_ireg)=R12; /*Rd defl disp, ena ints*/ JUMP (PC, return_address) (DB); IMASK=R4; /*Set new mask*/ BIT SET MODE1 0x1000; /*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; /*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: R1=R12 AND R1, R4=IMASK; /*Read old interrupt mask*/ R4=R1 OR R4, rammem(next_mask, ram_ireg)=R12; /*Next mask to defl, ena int*/ 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 */ /* 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 state */ RETURN (DB); RESTORE_STACK RESTORE_FRAME error_return: JUMP (PC, restore_state) (DB); R0=SIG_ERR; FETCH_RETURN .ENDSEG;