
 IF :DEF:|ads$version| 
      PRESERVE8 
     AREA |syscpu$$code|, CODE, READONLY
 ELSE 
    AREA |syscpu$$code|, CODE, READONLY, INTERWORK
 ENDIF



























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































      CODE32


      EXPORT GSMDisableInterrupts
      EXPORT GSMRestoreCPUState
      EXPORT GSMDisableALLInterrupts
      EXPORT GSMRestoreALLCPUState
      EXPORT SlowClkDis
      EXPORT RefOscRequest
      EXPORT GSMGetPrevARMSP
      EXPORT SysWriteByte2Peripheral
      EXPORT HPE_DSP_RESET

      IMPORT DisIntsLinkRegister
      IMPORT DisIntsStartTime
      IMPORT DisIntsEndTime
      IMPORT GSMExitIntsDisabledTooLong
      IMPORT InterruptTooLongTime
      IMPORT DisIntsTimeOverrun 
      IMPORT GSMExit


      EXPORT |$Sub$$_fp_trapveneer|
|$Sub$$_fp_trapveneer|
      STMDB  sp!,{r0}
      LDR    r0,=2501
      B GSMExit

      EXPORT |$Sub$$_fp_trap|
|$Sub$$_fp_trap|
      STMDB  sp!,{r0}
      LDR    r0,=2500
      B GSMExit

      EXPORT __rt_div0
__rt_div0
      STMDB  sp!,{r0}
      LDR    r0,=2502
      B GSMExit


GSMDisableALLInterrupts
GSMDisableInterrupts
      MRS  r0,cpsr        

      ORR  r1,r0,#&C0     
      MSR  cpsr_cxsf,r1   

      TST  r0,#0xC0       
      BNE  DisIntsDone    

      LDR  r1,=(0x700C5000 + 0x034) 
      LDR  r1,[r1]
      LDR  r2,=|DisIntsStartTime| 
      STR  r1,[r2]

DisIntsDone
      BX   lr             


GSMRestoreALLCPUState
GSMRestoreCPUState
      TST   r0,#0xC0
      BNE   EnableInts      

      LDR   r1,=(0x700C5000 + 0x034)  
      LDR   r1,[r1]

      LDR   r2,=|DisIntsStartTime|
      LDR   r2,[r2]

      CMP   r2,r1           
      BLT   EnableInts      

      SUB   r1,r2,r1        
      LDR   r2,=|InterruptTooLongTime|
      LDR   r2,[r2]
      CMP   r1,r2          

      BLT   EnableInts      

      LDR   r3,=|DisIntsLinkRegister| 
      STR   r14,[r3]        
      LDR   r3,=|DisIntsEndTime|
      STR   r1,[r3]         
      B     DisIntsTimeOverrun 

EnableInts      
      MSR  cpsr_cxsf,r0    
      BX   lr         

    CODE16                              


HPE_DSP_RESET


          STR      r2,[r0,#0]
          STR      r1,[r0,#0x10]
          BX       lr
          NOP                               



 IF :DEF:|ads$version| 
    IMPORT lib_heap
    EXPORT __user_initial_stackheap

__user_initial_stackheap    
    LDR   r0, =lib_heap
    MOV   pc,lr
 ENDIF  


   EXPORT InstructionWaits

InstructionWaits
   LSR  r0,#2 
ContinueWaiting
   CMP r0,#0 
   BEQ InstructionWaitsReturnToCaller 
   SUB r0,#1 
   B ContinueWaiting 
InstructionWaitsReturnToCaller
   MOV pc, lr 


      CODE32
GSMGetPrevARMSP
      MRS   r1,cpsr    
      AND   r3,r1,#&1F 
      AND   r2,r0,#&1F 
      CMP   r2,r3      
      BEQ   EasySP     
      CMP   r2,#&10    
      BEQ   ShitSP     
      BIC   r3,r1,#&1F 
      ORR   r3,r3,r2   
      MSR   cpsr_cxsf,r3    
      MOV   r0,r13
      MSR   cpsr_cxsf,r1    
      BX    lr         
ShitSP
      SUB   sp,sp,#4   
      STMFD sp,{r13}^  
      NOP                     
      LDMFD sp!,{r0}   
      BX    lr         
EasySP
      MOV   r0,r13     
      BX    lr         



 IF :DEF:|ads$version| 
     PRESERVE8 
     AREA IRAM_8Bit_Wr_Code, CODE, READONLY
 ELSE 
     AREA IRAM_8Bit_Wr_Code, CODE, READONLY, INTERWORK
 ENDIF



SysWriteByte2Peripheral

   MRS r2,cpsr 
   ORR r3,r2,#&C0 
   MSR cpsr_cxsf,r3 

   STRB r1,[r0] 

   MOV r1,#0x20000000 
   LDR r1,[r1] 

   NOP 
   NOP
   NOP
   NOP
   NOP

   MSR cpsr_cxsf,r2 

   BX lr 



   AREA Startup_bss, DATA, READWRITE, NOINIT
SlowClkDis
      DCD   0
RefOscRequest      
      DCD   0
      END
