⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 disk.a86

📁 一个dos操作系统DRDOS的源码
💻 A86
📖 第 1 页 / 共 3 页
字号:
	call	return_DX		; number of clusters and return

	mov	al,es:DDSC_CLMSK[bx]	; get (sectors per cluster)-1
	inc	ax			; return sectors per cluster
	lea	bx,DDSC_MEDIA[bx]	; return address of media byte
f1B1C1F32_common:
	push	ds
	lds	di,int21regs_ptr
	mov	reg_DS[di],es
	mov	reg_BX[di],bx
	pop	ds
	ret

;	*****************************
;	***    DOS Function 1F    ***
;	***    Get Default DPB    ***
;	*****************************
;
	Public	func1F
func1F:

;	*****************************
;	***    DOS Function 32    ***
;	***   Get Requested DPB   ***
;	*****************************
;
	Public	func32
func32:
	call	set_retry_RF		; Valid to RETRY or FAIL
	mov	dh,80h			; set top bit - free space not needed
	call	fdos_DISKINFO		; and make the function call
	 jnc	f1B1C1F32_common	; exit using common code
fdos_DI_error:
	jmp	fcberror_exit		; exit thru FCB error


;	*****************************
;	***    DOS Function 36    ***
;	***    Disk Free Space    ***
;	*****************************
;
	Public	func36
func36:
	call	set_retry_RF		; Valid to RETRY or FAIL
	xor	dh,dh			; clear out DH
	call	fdos_DISKINFO		; find out about drive
	 jnc	f36_OK			; CY set if we had a problem
	push	es
	push	bx
	call	error_exit		; generate a critical error
	pop	bx
	pop	es
	mov	ax,0FFFFh		; Invalid Drive Return 0FFFFh
	 jc	f36_exit		; No Carry
f36_OK:
	mov	cx,es:DDSC_SECSIZE[bx]	; Get the Physical Sector Size
	call	return_CX		; in bytes

	mov	dx,es:DDSC_NCLSTRS[bx]	; Convert the last cluster no
	dec	dx			; returned in DDSC to maximum
	call	return_DX		; number of clusters

	mov	cx,es:DDSC_FREE[bx]	; get number of free clusters
if DELWATCH
	add	cx,FD_ADJUST		; now add in DELWATCH adjustment
endif
	xor	ax,ax
	mov	al,es:DDSC_CLMSK[bx]	; get the sectors per cluster -1
	inc	ax			; AX = sectors per cluster

	mov	bx,cx
	call	return_BX		; return free clusters

f36_exit:
	jmp	return_AX_CLC

fdos_DISKINFO:
;-------------
; Called by func1B, func1C, func1F, func32, func36
; Even number functions have drive in DL
; Odd numbered function use default drive (0)
; 
	mov	ax,FD_DISKINFO		; get information about drive
	xchg	ax,FD_FUNC		; while getting orginal function #
	test	al,1			; is it func1B/func1F ?
	 jz	fdos_DI10		; if so these use the default
	xor	dl,dl			;  drive so zero DL
fdos_DI10:
	mov	FD_DRIVE,dx		; drive in DX
	call	fdos_crit
	les	bx,FD_DPB		; get the DPB pointer
	ret

eject
;	*****************************
;	***    DOS Function 2F    ***
;	***   Get Disk Trans Adr  ***
;	*****************************

	Public	func2F
func2F:
	les	bx,dword ptr dma_offset	; current dma address
	push	ds
	lds	di,int21regs_ptr
	mov	reg_ES[di],es
	mov	reg_BX[di],bx
	pop	ds
	ret


eject
;	*****************************
;	***    DOS Function 41    ***
;	***    Delete File(s)     ***
;	*****************************
;
	Public	func41
func41:
	cmp	ss:remote_call,0
	 jne	fdos_common41
	mov	cl,06h

;	*****************************
;	***    DOS Function 39    ***
;	***  Create SubDirectory  ***
;	*****************************
;
	Public	func39
func39:

;	*****************************
;	***    DOS Function 3A    ***
;	***  Delete SubDirectory  ***
;	*****************************
;
	Public	func3A
func3A:

;	*****************************
;	***    DOS Function 3B    ***
;	***  Change SubDirectory  ***
;	*****************************
;
	Public	func3B
func3B:
;	*****************************
;	***    DOS Function 4E    ***
;	***    Find First File    ***
;	***    DOS Function 4F    ***
;	***    Find Next File     ***
;	*****************************
;
	Public	func4E
func4E:
	Public	func4F
func4F:
; Func 4F has no parameters, but using the same routine saves code

fdos_common41:
	call	set_retry_RF		; Valid to RETRY or FAIL
;	jmps	fdos_name

fdos_name:
	mov	FD_NAMEOFF,dx		; Initialise Pointer
	mov	FD_NAMESEG,es
	mov	FD_ATTRIB,cx		; and attributes
	jmp	fdos_ax_crit

eject
;	*****************************
;	***    DOS Function 5B    ***
;	***   Create New File     ***
;	*****************************
;
	Public	func5B
func5B:

;	*****************************
;	***    DOS Function 3C    ***
;	***     Create a File     ***
;	*****************************
;
	Public	func3C
func3C:
	call	set_retry_RF		; Valid to RETRY or FAIL
	cmp	FD_FUNC,MS_X_CREAT	; is it a standard create ?
	 je	f3C_10
	mov	FD_FUNC,FD_NEW		; no, create a new file
f3C_10:
	mov	FD_MODE,DHM_RW		; create as read/write
	jmps	fdos_name		; go do it

;	*****************************
;	***    DOS Function 3D    ***
;	***      Open a File      ***
;	*****************************
;
	Public	func3D
func3D:
	call	set_retry_RF			; Valid to RETRY or FAIL
	cmp	ss:remote_call,0
	 jne	funcExtendedOpenCreate
	mov	cl,06h				; default search mode for local
;	jmp	funcExtendedOpenCreate		;  calls (remote it's in CL)
funcExtendedOpenCreate:
; On Entry:
;	FD_FUNC = function to carry out
;	ES:DX -> name
;	AX = open mode
;	CX = file attributes
;
	push	ax
	and	al,DHM_SHAREMSK
	cmp	al,DHM_DENY_NONE		; any funny share bits ?
	pop	ax
	 ja	open_mode_err
	push	ax
	and	al,DHM_RWMSK
	cmp	al,DHM_RW			; check RW bits are valid
	pop	ax
	 ja	open_mode_err
	mov	FD_MODE,ax			; Set Open Mode
	jmps	fdos_name

open_mode_err:
	mov	ax,ED_ACC_CODE			; This is an illegal open mode
	jmp	error_exit			;  return an error


;	*****************************
;	***    DOS Function 3F    ***
;	***    Read from Handle   ***
;	*****************************
;
	Public	func3F
func3F:

;	*****************************
;	***    DOS Function 40    ***
;	***    Write to a Handle  ***
;	*****************************
;
	Public	func40
func40:
	mov	al,OK_RIF			; Valid to RETRY,IGNORE or FAIL
	call	set_retry
	mov	FD_BUFOFF,dx
	mov	FD_BUFSEG,es
	mov	FD_COUNT,cx
	call	fdos_handle
	mov	dx,FD_COUNT
	 jnc	f40_10				; no error, return # xfered
	push	FD_HANDLE
	push	dx				; an error, try critical error
	call	error_exit			;  and if we get back here that
	pop	dx				;  means we Fail/Ignore it
	pop	bx
	 jc	f40_20				; are we returning an error ?
	push	dx				; no, we are ignoring it
	xor	cx,cx				;  CX:DX offset to skip
	mov	ax,(MS_X_LSEEK*256)+1		;  seek to current+offset
    call    dos_entry           
	pop	dx				; finally return # we wanted
f40_10:						;  to xfer
	xchg	ax,dx				; AX = return code
	jmp	return_AX_CLC
f40_20:
	ret

;	*****************************
;	***    DOS Function 42    ***
;	***    Move R/W Pointer   ***
;	*****************************
;
	Public	func42
func42:
	call	set_retry_RF			; Valid to RETRY or FAIL
	mov	word ptr FD_OFFSET+0,dx
	mov	word ptr FD_OFFSET+2,cx
	mov	FD_METHOD,ax
	call	fdos_handle
	 jc	f42_error			; Do not return the current
	mov	ax,word ptr FD_OFFSET+0		; file position if
	mov	dx,word ptr FD_OFFSET+2		; an error occurs
	call	return_DX
	jmp	return_AX_CLC

f42_error:
	jmp	error_exit

fdos_handle:
	mov	FD_HANDLE,bx
	jmp	fdos_crit

;	*****************************
;	***    DOS Function 43    ***
;	***    Change File Mode   ***
;	*****************************
;
;	Concurrent Password Support:-
;
;	     *WO* *GR* *OW*		This is the format of the Password
;	P---$RWED$RWED$RWED 		mode word which is compatible with
;					the FlexOS F_PROTECT field.
;	*WO* World (Ignored)
;	*GR* Group (Ignored)		The P flag is only used to designate
;	*OW* Owner (Used)		that the password is being updated.
;
	Public	func43
func43:
	call	set_retry_RF		; Valid to RETRY or FAIL
	mov	FD_FLAG,ax		; Requested Attributes ignored
	call	fdos_name		; if flags are not being set
	 jc	f42_error
	call	reload_registers	; get back AL
	test	al,81h
     jnz    f43_exit        
	mov	cx,FD_ATTRIB
	call	return_CX		; Return Attribs/Password
	xchg	ax,cx			; Also in AX
f43_exit:
	jmp	return_AX_CLC

;	*****************************
;	***    DOS Function 46    ***
;	***    Force Dup Handle   ***
;	*****************************
;
	Public	func46
func46:
	xchg	bx,cx			; destination handle in BX
	mov	ah,MS_X_CLOSE		; try to close it but ignore
	call	dos_entry		;  errors as it may be already
	xchg	bx,cx			; now fall thru to handle func
	mov	ah,MS_X_DUP2		;  do do the duplicate
	
;	*****************************
;	***    DOS Function 45    ***
;	***    Duplicate Handle   ***
;	*****************************
;
	Public	func45
func45:

;	*****************************
;	***    DOS Function 3E    ***
;	***      Close a File     ***
;	*****************************
;
	Public	func3E
func3E:
	mov	al,OK_FAIL
	call	set_retry		; Valid to FAIL
	mov	FD_NEWHND,cx		; (in case it's force dup)
;	jmps	fdos_ax_handle

fdos_ax_handle:
	mov	FD_HANDLE,bx
	jmp	fdos_ax_crit

;	*****************************
;	***    DOS Function 5C    ***
;	***Lock/Unlock File Access***
;	*****************************
;
	Public	func5C
func5C:
	call	set_retry_RF		; Valid to RETRY or FAIL
	mov	FD_FUNC,FD_LOCK		; Lock/Unlock File
	mov	word ptr FD_OFFSET+0,dx	; Lock Offset (LOW)
	mov	word ptr FD_OFFSET+2,cx	; Lock Offset (HIGH)
	mov	word ptr FD_LENGTH+0,di	; Lock Length (LOW)
	mov	word ptr FD_LENGTH+2,si	; Lock Length (HIGH)
	mov	FD_LFLAG,ax		; Lock Type
	jmps	fdos_ax_handle

;	*****************************
;	***    DOS Function 47    ***
;	***    Get Current Dir    ***
;	*****************************
;
	Public	func47
func47:
	call	set_retry_RF		; Valid to RETRY or FAIL
	mov	FD_PATHOFF,si		; Initialise Pointer

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -