;References:
;swi - vector_handler_forward
;swi_OS_Module - vector_handler_trap

.vector_handler_8
 AND     R14, R0, #&FF			;bit 31 is set if OS_SynchroniseCodeArea is to be called
 TEQ     R14, #12
 TEQNE   R14, #14			;PRM2-43
 TEQNE   R14, #16
 TEQNE   R14, #255			;is it a load operation?
 BNE     vector_handler_forward		;NO

 LDR     R14, jit_code			;is the JIT running?
 TEQ     R14, #0
 BEQ     vector_handler_forward		;NO, hand to OS

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

 STMFD   R13!, {R10, R11}		;preserve R10, R11
 ADR     R12, _SPSR
 MRS     R10, SPSR			;preserve SPSR for reentry via FileV vector
 TST     R3, #%11111111			;is there an address in R2?
 MOVNE   R11, #0			;NO, OS_File will return load address
 MOVEQ   R11, R2			;YES, R11=load address
 BL      pre_SWI_veneer			;call SWI that follows
 SWI     XOS_File			;PRM2-32  R2=load address
 STR     R10, [R12, #0]			;overwrite exit SPSR
 BL      post_SWI_veneer
 BL      dontexit_SWI_veneer
 LDMVSFD R13!, {R10-R12, PC}^		;exit on error

 STR     R2, [R13, #-4]!		;preserve R2
 TEQ     R11, #0			;did we specify the load address?
 MOVNE   R2, R11			;YES, use our load address
 BNE     _know_address

 MOV     R11, #&FFF
 AND     R10, R2, R11, LSL #20
 TEQ     R10, R11, LSL #20		;is the file date stamped?
 BNE     _know_address			;NO

 AND     R10, R2, R11, LSL #8		;get the filetype
 EORS    R10, R10, #&FF8 << 8		;is it Absolute?
 MOVEQ   R2, #&8000			;YES, the file was loaded at &8000
 ._know_address
 CMP     R2, #jit_appspace_end		;is it in application space?
 BLLO    hv_reset_memory_block		;YES, reset JIT appspace
LDMFD   R13!, {R2, R10-R12, PC}^


 ._SPSR     DBD 4
