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

      CODE32

      EXPORT GSMMalloc
      EXPORT GSMMallocNULL

      EXPORT GSMMalloc_Traced 
      EXPORT GSMMallocNULL_Traced


      IMPORT GSMMallocNULLDebug
      IMPORT GSMMallocDebug
      IMPORT GSMTraceNULLMalloc


GSMMallocNULL
      STMFD r13!, {lr}    
      LDR   r1, =GSMMallocNULLDebug
      MOV   lr,pc
      BX    r1
      LDMFD r13!, {lr} 

      CMP r0,#0
      BNE GSMMallocStoreHeadAndReturn

      MOV r0, lr
      STMFD r13!, {lr}    
      LDR  r1,=GSMTraceNULLMalloc
      MOV   lr,pc
      BX    r1
      LDMFD r13!, {lr} 

      MOV r0, #0
      BX   lr             

GSMMalloc
      STMFD r13!, {lr}    
      LDR   r1, =GSMMallocDebug
      MOV   lr,pc
      BX    r1
      LDMFD r13!, {lr} 

GSMMallocStoreHeadAndReturn



      STR   lr,[r0,#-8]  



      BX   lr             


GSMMalloc_Traced
      STMFD r13!, {lr}    
      LDR   r2, =GSMMallocDebug
      MOV   lr,pc
      BX    r2
      LDMFD r13!, {lr}



      LDR  r1,[sp,#4]
      STR   r1,[r0,#-8]  




      BX   lr             
GSMMallocNULL_Traced
      STMFD r13!, {lr}    
      LDR   r2, =GSMMallocNULLDebug
      MOV   lr,pc
      BX    r2
      LDMFD r13!, {lr}



      LDR r1,[sp,#4]
      STR   r1,[r0,#-8]  




      BX   lr             


      END
