;References:
;swi - vector_handler_forward

;R12, R14 are on the stack

#set DA2_magic_number = &F0000002

;vector_handler_5C
;-----------------
;Returns the RO3.1 address for DA2

.vector_handler_5C
 TEQ     R0, #DA2_magic_number		;are we calling for the OS DA2 info?
 MOVEQ   R0, #2				;YES
 BEQ     vector_handler_forward		;pass call onto OS

 CMN     R0, #1				;CLib asking for appspace end?
 BNE     _P1				;NO

 #if JIT_WIMP_support == 1
   BL      check_task_ID		;is the task supported?
   BNE     vector_handler_forward	;NO
 #endif

 LDR     R12, jit_code			;YES
 TEQ     R12, #0			;is the JIT running?
 BEQ     _P1				;NO

 MOV     R0, #&8000			;YES, start
 MOV     R2, #jit_allocate_memory	; |   end
 SUB     R1, R2, R0			; |+  size
B       vector_handler_trap		;return to original caller

 ._P1
 LDR     R12, emulate_RISCOS
 CMP     R12, #&350 << 8		;don't remap RO3.50+
 BHS     vector_handler_forward

 TEQ     R0, #2				;screen DA?
 TEQNE   R0, #2 + (1<<7)
 BNE     vector_handler_forward		;NO, pass to OS

 LDR     R12, is_screen_remapped
 TEQ     R12, #0			;is screen memory remapped?
 BEQ     vector_handler_forward		;NO, pass call onto OS

 LDR     R12, [R13, #4]			;get PC from stack
 #if compile_RO == 400
   BIC     R12, R12, #&FC000003		;clear PSR
 #endif
 CMP     R12, #jit_slotsize		;is it the OS asking?
 BHI     vector_handler_forward		;YES, pass on

 TST     R0, #1 << 7			;do we need to return the max size?
 MOVNE   R2, #480 * 1024		;max DA2 size on RO3.1

 MOV     R0, #&2000000			;RO3.1 DA2 end
 LDR     R1, DA2_size			;DA2 size
 SUB     R0, R0, R1			;RO3.1 DA2 start
B       vector_handler_trap		;return to original caller