Listing 2. Interrupt Handlers
___lib_start:
  call ___lib_setup_c;  /* Setup C runtime model */
  jump _main;   /* Begin C program */

___lib_prog_term:
  pm(__done_execution)=PC;
  idle;
  jump ___lib_prog_term;


DSP_K_INTR_RAPPER_0:
  push sts;
DSP_K_INTR_RAPPER:
  bit tst ustat2 0x8;  /* in interrupt? */
  if not tf jump DSP_K_INTR_RAPPER_1;
    /* study pcstk to see where we were */
  jump ___lib_prog_term;

DSP_K_INTR_RAPPER_1:
  bit set ustat2 0x8;  /* flag in interrupt */
    /* select reqd shadow registers */
  bit set mode1 0x0490;
  nop;
  r0=i7;   /* remember stack */
  r1=i6;   /* and frame */
    /* select remaining shadow registers */
  bit set mode1 0x0008;
  r4 = ustat1;
  i6=r1;   /* set frame */
  i7=r0;   /* and stack */
    /* The simulator fails to store ASTAT across 
       delayed interrupt vectoring. Test for 
       silicon revision 0. */
  ustat1 = astat; /* astat kept across vectoring */
  r0 = mode2; /* get silicon rev. (simulator is 0)*/
  r1 = 0x30000000; /* value for silicon rev. 0 */
  r0 = r0 and r1; /* simulator (or rev. 0)? */
  if ne jump (pc,0x7); /* if not, no problem */

  pop sts; /* pop off bad astat (+good mode1) */
  astat = ustat1; /* fix astat */
    /* do what simulator should've done and
       redisable (pop sts undoes) */
  push sts; 
  bit clr mode1 0x1000;
  bit set mode1 0x498; /* re-set shadow */
  nop;

    /* preserve i12 when interrupt over 'return' */
  dm(i7,m7)=i12;
    /* program stack bound unlimited in shadow */
  ustat1 = i7;
  b7=0;
  l7=0x7fffffff;
  i7 = ustat1;
    /* call C interrupt routine */
  cjump __DSP_K_INTR_RAPPER (db);
  dm(i7,m7)=r2;
  dm(i7,m7)=pc;

    /* restore i12 when interrupt over 'return' */
  modify(i7,m6);
  i12=dm(i7,m5);  
    /* de-select shadow registers */
  bit clr mode1 0x0498;
    /* mark out of interrupt */
  bit clr ustat2 0x8;

DSP_K_INTR_RAPPEREND:
  rti( db );
    /* all that vector to DSP_K_INTR_RAPPER_0 must
       be closed here (CB7 never returns) */
# if( DSP_K_TIMER_SIG == SIG_TMZ )&& \
    ( SHARC == __ADSP21065L__ )
    pop sts;
    bit set mode1 0x1000;
# else
    nop;
    nop;
# endif
.endseg;