;Entry:
; R11 - pointer to commandline
; R12 - pointer to VARS
;
;Exit:
; R0 - error or 0
; R1-R11 - corrupted

.Entry_ADFMount_ADF
 MOV     R0, #17			;read file information
 MOV     R1, R11			;point to filename
 SWI     XOS_File			;PRM2-38
 BVS     Entry_ADFMount_Exit		;exit on error

 LDR     R2, [R12, #File_Size_Limit - VARS]
 CMP     R4, R2				;is filesize above our limit?
 ADRHI   R0, Error_File_Size		;YES, point to error
 BHI     Entry_ADFMount_Exit		;  +- exit on error
 BL      MemAlloc			;Allocate memory
 BVS     Entry_ADFMount_Exit		;exit on error

 MOV     R1, R11			;filename
 MOV     R0, #&4F			;open read only
 SWI     XOS_Find			;PRM2-78
 BVS     Entry_ADFMount_Exit		;exit on error

 MOV     R1, R0				;file handle
 MOV     R0, #4				;read from current pointer
 LDR     R2, [R12, #DA_address - VARS]	;address to load file
 STR     R2, [R12, #ADF_Buffer_Address - VARS]
 MOV     R3, R4
 SWI     XOS_GBPB			;PRM2-69
 MOVVS   R4, R0				;preserve any error
 MOVVS   R2, #Type_None			;mark ADF FS as empty
 MOVVC   R2, #Type_ADF			;loaded okay if V clear
 BL      floppy_type_changed

 MOV     R0, #0				;close file
 SWI     XOS_Find			;close the file PRM2-77
 TEQ     R2, #0				;did an error occur?
 MOVEQ   R0, R4				;YES
 BEQ     Entry_ADFMount_Exit		;exit on error
B       Entry_ADFMount_mounted
