/* This C language subroutine provides an interface to the input flags of the ADSP-21020. The Run Time Library for the C Language. Gordon A. Sterling (617) 461 - 3076 DSP Development Tools Engineering Created on 01/07/91 The function returns 0 for modes [0,4], and the flag value (0 or 1) for any other mode. An invalid flag will result in a -1 return value. #include <21020.h>
int poll_flag_in(int flag, int mode); flag = { 0, 1, 2, 3 } mode = { 0 = transition lo to hi 1 = transition hi to lo 2 = flag hi 3 = flag low 4 = transition other = read only flag } */ #include "lib_glob.h" #include "020_glob.h" .SEGMENT/CODE Code_Space_Name; .FILE RTL_FILENAME; .GLOBAL _poll_flag_in; _poll_flag_in: R4=PASS R4, R0=dm_0; /*Test for flag 0, return 0*/ IF EQ JUMP (PC, tst_0) (DB); R4=R4-1; FETCH_RETURN /* Fetches Return addr from the start */ IF EQ JUMP (PC, tst_1); R4=R4-1; IF EQ JUMP (PC, tst_2); R4=R4-1; IF EQ JUMP (PC, tst_3); error_return: R0=-1; /*Error return*/ JUMP (PC, restore_state); tst_0: R8=PASS R8; IF EQ JUMP (PC, trans_lo_to_hi0); R8=R8-1; IF EQ JUMP (PC, trans_hi_to_lo0); R8=R8-1; IF EQ JUMP (PC, lo_to_hi0); R8=R8-1; IF EQ JUMP (PC, hi_to_lo0); R8=R8-1; IF EQ JUMP (PC, trans0); /*If the input is not 0-4, return flag*/ JUMP (PC, restore_state) (DB); IF FLAG0_IN R0=R0+1; nop; trans0: IF FLAG0_IN JUMP (PC, hi_to_lo0); JUMP (PC, lo_to_hi0); trans_lo_to_hi0:IF NOT FLAG0_IN JUMP (PC, lo_to_hi0); /*These two cycles are needed*/ IF FLAG0_IN JUMP (PC, trans_lo_to_hi0); /* would be un-interruptable*/ lo_to_hi0: IF FLAG0_IN JUMP (PC, restore_state); IF NOT FLAG0_IN JUMP (PC, lo_to_hi0); JUMP (PC, restore_state); trans_hi_to_lo0:IF FLAG0_IN JUMP (PC, hi_to_lo0); IF NOT FLAG0_IN JUMP (PC, trans_hi_to_lo0); hi_to_lo0: IF NOT FLAG0_IN JUMP (PC, restore_state); IF FLAG0_IN JUMP (PC, hi_to_lo0); JUMP (PC, restore_state); tst_1: R8=PASS R8; IF EQ JUMP (PC, trans_lo_to_hi1); R8=R8-1; IF EQ JUMP (PC, trans_hi_to_lo1); R8=R8-1; IF EQ JUMP (PC, lo_to_hi1); R8=R8-1; IF EQ JUMP (PC, hi_to_lo1); R8=R8-1; IF EQ JUMP (PC, trans1); JUMP (PC, restore_state) (DB); IF FLAG1_IN R0=R0+1; NOP; trans1: IF FLAG1_IN JUMP (PC, hi_to_lo1); JUMP (PC, lo_to_hi1); trans_lo_to_hi1:IF NOT FLAG1_IN JUMP (PC, lo_to_hi1); /*These two cycles are needed*/ IF FLAG1_IN JUMP (PC, trans_lo_to_hi1); /* would be un-interruptable*/ lo_to_hi1: IF FLAG1_IN JUMP (PC, restore_state); IF NOT FLAG1_IN JUMP (PC, lo_to_hi1); JUMP (PC, restore_state); trans_hi_to_lo1:IF FLAG1_IN JUMP (PC, hi_to_lo1); IF NOT FLAG1_IN JUMP (PC, trans_hi_to_lo1); hi_to_lo1: IF NOT FLAG1_IN JUMP (PC, restore_state); IF FLAG1_IN JUMP (PC, hi_to_lo1); JUMP (PC, restore_state); tst_2: R8=PASS R8; IF EQ JUMP (PC, trans_lo_to_hi2); R8=R8-1; IF EQ JUMP (PC, trans_hi_to_lo2); R8=R8-1; IF EQ JUMP (PC, lo_to_hi2); R8=R8-1; IF EQ JUMP (PC, hi_to_lo2); R8=R8-1; IF EQ JUMP (PC, trans2); JUMP (PC, restore_state) (DB); IF FLAG2_IN R0=R0+1; NOP; trans2: IF FLAG2_IN JUMP (hi_to_lo2); JUMP (PC, lo_to_hi2); trans_lo_to_hi2:IF NOT FLAG2_IN JUMP (PC, lo_to_hi2); /*These two cycles are needed*/ IF FLAG2_IN JUMP (PC, trans_lo_to_hi2); /* would be un-interruptable*/ lo_to_hi2: IF FLAG2_IN JUMP (PC, restore_state); IF NOT FLAG2_IN JUMP (PC, lo_to_hi2); JUMP (PC, restore_state); trans_hi_to_lo2:IF FLAG2_IN JUMP (PC, hi_to_lo2); IF NOT FLAG2_IN JUMP (PC, trans_hi_to_lo2); hi_to_lo2: IF NOT FLAG2_IN JUMP (PC, restore_state); IF FLAG2_IN JUMP (PC, hi_to_lo2); JUMP (PC, restore_state); tst_3: R8=PASS R8; IF EQ JUMP (PC, trans_lo_to_hi3); R8=R8-1; IF EQ JUMP (PC, trans_hi_to_lo3); R8=R8-1; IF EQ JUMP (PC, lo_to_hi3); R8=R8-1; IF EQ JUMP (PC, hi_to_lo3); R8=R8-1; IF EQ JUMP (PC, trans3); JUMP (PC, restore_state) (DB); IF FLAG3_IN R0=R0+1; NOP; trans3: IF FLAG3_IN JUMP (PC, hi_to_lo3); JUMP (PC, lo_to_hi3); trans_lo_to_hi3:IF NOT FLAG3_IN JUMP (PC, lo_to_hi3); /*These two cycles are needed*/ IF FLAG3_IN JUMP (PC, trans_lo_to_hi3); /* would be un-interruptable*/ lo_to_hi3: IF FLAG3_IN JUMP (PC, restore_state); IF NOT FLAG3_IN JUMP (PC, lo_to_hi3); JUMP (PC, restore_state); trans_hi_to_lo3:IF FLAG3_IN JUMP (PC, hi_to_lo3); IF NOT FLAG3_IN JUMP (PC, trans_hi_to_lo3); hi_to_lo3: IF NOT FLAG3_IN JUMP (PC, restore_state); IF FLAG3_IN JUMP (PC, hi_to_lo3); JUMP (PC, restore_state); restore_state: FETCH_RETURN RETURN (DB); RESTORE_STACK RESTORE_FRAME .ENDSEG;