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

📄 dosif.asm

📁 一个dos操作系统DRDOS的源码
💻 ASM
📖 第 1 页 / 共 5 页
字号:
	pop	cx
	pop	dx
	pop	di
	pop	si
	pop	es
	pop	ds
	pop	bp
	ret 

_logical_drive	ENDP

	public	_network_drive
_network_drive	PROC NEAR

;	BOOLEAN	network_drive(WORD);
;	returns TRUE if given drive (0-25) is networked
;
	push	bp
	mov	bp,sp
	push	dx
	push	cx
	push	bx
	
	mov	bx,4[bp]	; get the drive number
	inc	bx		; A=1, B=2, etc
	mov	ax,4409h	; IOCTL Network/Local
	int	21h		; do it
	jc	not_networked	; carry means invalid drive
	and	dx,1000h	;
	cmp	dx,0
	jne	not_networked	; its a network drive

	mov	ax,-1
	jmp 	network_exit
not_networked:
	mov	ax,0
network_exit:
	pop	bx
	pop	cx
	pop	dx
	pop	bp
	ret 

_network_drive	ENDP

endif	;EXT_SUBST

else	;!DOSPLUS
	
	Public	_physical_drvs		; Physical Drives returns a LONG
_physical_drvs:				; Vector with bits set for every
	mov	cx,DRV_LOGINVEC		; Physical or Networked Drive 
	int	BDOS_INT		; attached to the system
	xor	dx,dx			; Return the LONG value in both
	mov	bx,dx			; AX:DX and AX:BX for maximum
	ret				; compatibility

	Public	_network_drvs		; Network Drives returns a LONG
_network_drvs:				; vector with bits set for every
	push	es			; physical drive which has been
	mov	ax,0			; mapped to a remote DRNET server
	mov	dx,ax
	les	bx,_pd			; Get Our Process Descriptor
	mov	cx,es:P_NDA[bx]		; and then the NDA Segment
	 jcxz	n_d20			; Skip Drive Test if no NDA
	mov	es,cx			; Get the RCT Address
	les	bx,es:dword ptr 04h	;; NDA_RCT ; From the NDA
	mov	cx,16
n_d10:
	test	es:RCT_DSK[bx],080h	; Is this a Remote drive
	 jz	n_d15			; No
	or	ax,1			; Set Drive Bit
n_d15:
	ror	ax,1			; Rotate Drive Bit Vector
	add	bx,2			; Update the Drive Pointer
	loop	n_d10			; Loop Till Done
n_d20:
	mov	bx,dx			; Return the long value in both
	pop	es			; AX:BX and AX:DX
	ret

ifndef	EXT_SUBST

	Public	_logical_drvs		; Logical Drives returns a LONG
_logical_drvs:				; vector with bits set for every
	push	es
	push	si
	push	di

	les	si,_pd			; Get Our Process Descriptor
	mov	si,es:P_CAT[si]		; and then the address of the 
	mov	cx,16			; first HDS and check the first
	mov	ax,0			; 16 Drives
	mov	bx,ax	

l_d10:
	mov	di,es:word ptr [si]	; Has this drive got an HDS
	test	di,di			; then skip setting the bit in 
	 jz	l_d20			; the vector register
	cmp	es:byte ptr [di],bl	; Is the HDS pointing to same drive
	 jz	l_d20			; Yes then this is a Physical Drive
	or	ax,1
l_d20:
	ror	ax,1
	add	si,2
	inc	bx
	loop	l_d10			; Loop 16 Tines

	mov	cx,10			; Finally check the last 10 HDS
	mov	dx,0
l_d30:
	mov	di,es:word ptr [si]	; Has this drive got an HDS
	test	di,di			; then skip setting the bit in 
	 jz	l_d40			; the vector register
	cmp	es:byte ptr [di],bl	; Is the HDS pointing to same drive
	 jz	l_d40			; Yes then this is a Physical Drive
	or	dx,1
l_d40:
	ror	dx,1
	add	si,2
	inc	bx
	loop	l_d30			; Loop 10 Tines

	mov	cl,6			; Now rotate the contents of 
	ror	dx,cl			; DX 6 more times for correct
					; alignment of bits
	pop	di
	pop	si
	pop	es
	mov	bx,dx			; Return the long value in both
	ret				; AX:BX and AX:DX


;
;	This function use the CONCURRENT 5.xx CP/M function to translate
;	a logical to physical drive.
;
	Public	_pdrive
;------
_pdrive:
;------
	push	bp
	mov	bp,sp
	mov	dl,4[bp]		; get the logical drive
	mov	cl,175			; Logical to Physical Xlat
	int	BDOS_INT
	cbw
	pop	bp
	CRET	2

endif	;!EXT_SUBST
endif	;!DOSPLUS


	Public	_toupper

UCASE	equ	18			; offset of dword ptr to uppercase func

;-------
_toupper	proc	near
;-------
; Return the uppercase equivilant of the given character.
; The uppercase function defined in the international info block is 
; called for characters above 80h.
;
; char	ch;				char to be converted
; char	result;				uppercase equivilant of ch
;
; result = toupper(ch);

	push	bp
	mov	bp, sp

	mov	ax, 4[bp]
	mov	ah, 0			; al = character to be converted
	cmp	al, 'a'			; al < 'a'?
	jb	exit_toupper		;  yes - done (char unchanged)
	cmp	al, 'z'			; al <= 'z'?
	jbe	a_z			;  yes - do ASCII conversion
	cmp	al, 80h			; international char?
	jb	exit_toupper		;  no - done (char unchanged)

; ch >= 80h  -- call international routine
	call	dword ptr [_country+UCASE]
	jmp	exit_toupper

a_z:
; 'a' <= ch <= 'z'  -- convert to uppercase ASCII equivilant
	and	al, 0DFh

exit_toupper:
	pop	bp
	ret

_toupper	endp



ifdef DOSPLUS
if 0
	Public	_hiload_status
;----------
_hiload_status:
;----------
	push	bp
	mov	bp,sp
	mov	dx,100h			; get hiload state
	mov	ax,(MS_X_IOCTL*256)+57h	; IO Control function
	int	DOS_INT			; do INT 21h
	pop	bp			; 
	ret

	Public	_hiload_set
;----------
_hiload_set:
;----------
	push	bp
	mov	bp,sp
	mov	dx,4[bp]		; get state
	mov	dh,2			; set hiload state
	mov	ax,(MS_X_IOCTL*256)+57h	; IO Control function
	int	DOS_INT			; do INT 21h
	pop	bp			; 
	ret
endif

	Public	_get_upper_memory_link
_get_upper_memory_link:

	mov	ax,5802h
	int	21h
	cbw
	ret

	Public	_set_upper_memory_link
_set_upper_memory_link:

	push	bp
	mov	bp,sp
	mov	bx,4[bp]
	mov	ax,5803h
	int	21h
	pop	bp
	ret

	Public	_get_alloc_strategy
_get_alloc_strategy:
	
	mov	ax,5800h
	int	21h
	ret

	Public	_set_alloc_strategy
_set_alloc_strategy:

	push	bp
	mov	bp,sp
	mov	bx,4[bp]
	mov	ax,5801h
	int	21h
	pop	bp
	ret

	Public	_alloc_region

_alloc_region:
	push	es
	xor	ax,ax
	mov	es,ax			; assume no block allocated
	mov	ah,MS_M_ALLOC
	mov	bx,1
	int	21h			; allocate a small block
	 jc	_alloc_region10
	mov	es,ax
	mov	ah,MS_M_SETBLOCK
	mov	bx,0FFFFh
	int	21h			; find out how big the block is
	mov	ah,MS_M_SETBLOCK
	int	21h			; now grow to take up the block
_alloc_region10:
	mov	ax,es			; return address of block
	pop	es
	ret

	Public	_free_region

_free_region:
	push	bp
	mov	bp,sp
	push	es
	mov	es,4[bp]
	mov	ah,MS_M_FREE
	int	21h			; free the block
	pop	es
	pop	bp
	ret

endif

; The Double Byte Character Set lead byte table.
; Each entry in the table except the last specifies a valid lead byte range.
;
;   0	+---------------+---------------+
;   	|    start of	|    end of 	|	DBCS table entry 0
;	|    range 0	|    range 0	|
;   2	+---------------+---------------+
;    	|    start of	|    end of 	|	DBCS table entry 1
;	|    range 1	|    range 1	|
;	+---------------+---------------+
;			:
;   n	+---------------+---------------+
;	|       0	|       0 	|	end of DBCS table
;	|    		|    		|
;	+---------------+---------------+


	Public	_dbcs_expected

_dbcs_expected	proc	near
;-------------
; Returns true if double byte characters are to be expected.
; A call to dbcs_init() MUST have been made.
; Entry
;	none
; Exit
;	ax	= 1 - double byte characters are currently possible
;		  0 - double byte characters are not currently possible

ifdef DOSPLUS
	push	ds
	push	si
	lds	si, dbcs_table_ptr	; DS:SI -> system DBCS table
	lodsw				; ax = first entry in DBCS table
	test 	ax, ax			; empty table?
	 jz	de_exit			;  yes - return 0 (not expected)
	mov	ax, 1			; return 1 (yes you can expect DBCS)
de_exit:
	pop	si
	pop	ds
else
	xor	ax,ax			; CDOS doesn't support them
endif
	ret
_dbcs_expected	endp


	Public	_dbcs_lead

_dbcs_lead	proc	near
;---------
; Returns true if given byte is a valid lead byte of a 16 bit character.
; A call to init_dbcs() MUST have been made.
; Entry
;	2[bp]	= possible lead byte
; Exit
;	ax	= 1 - is a valid lead byte
;		  0 - is not a valid lead byte

ifdef DOSPLUS
	push	bp
	mov	bp, sp
	push	ds
	push	si

	mov	bx, 4[bp]		; bl = byte to be tested
	lds	si,dbcs_table_ptr	; ds:si -> system DBCS table
	lodsw				; any entries ?
	test	ax,ax
	 jz	dl_not_valid		; no DBC entries

dl_loop:
	lodsw				; al/ah = start/end of range
	test 	ax, ax			; end of table?
	 jz	dl_not_valid		;  yes - exit (not in table)
	cmp	al, bl			; start <= bl?
	 ja	dl_loop			;  no - try next range
	cmp	ah, bl			; bl <= end?
	 jb	dl_loop			;  no - try next range

	mov	ax, 1			; return 1 - valid lead byte

dl_not_valid:
	pop	si
	pop	ds
	pop	bp
else
	xor	ax,ax			; CDOS doesn't support them
endif
	ret
_dbcs_lead	endp


	PUBLIC	_extended_error
_extended_error PROC NEAR

	mov	ah,59h
	mov	bx,0
	int	21h
	neg	ax
	ret

_extended_error	ENDP

	PUBLIC	_get_lines_page
_get_lines_page PROC NEAR

	push	bp
	push	es

	mov	ax,1130h
	mov	bx,0
	mov	dx,24	; preset dx to 24 in case function not supported 
	int	10h	 
	
	mov	ax,dx	; returns (no. rows)-1 in dx
	inc	ax

	pop	es
	pop	bp
	ret
	
_get_lines_page ENDP

	PUBLIC	_get_scr_width
_get_scr_width PROC NEAR

	push	bp
	mov	ah,0fh
	int	10h
	xor	al,al
	xchg	ah,al
	pop	bp
	ret
	
_get_scr_width ENDP

	PUBLIC	_novell_copy
_novell_copy PROC NEAR

	push	bp
	mov	bp,sp
	push	si
	push	di
	
	mov	ax,11f0h
	mov	si,4[bp]	; si = source handle
	mov	di,6[bp]	; di = destination handle
	mov	dx,8[bp]	; lo word of source length
	mov	cx,10[bp]	; hi word of source length
	clc			; start with carry cleared
	
	int	2fh		; do it

	jc	novcop_failure	; carry set means novell couldn't handle it

	cmp	ax,11f0h	
	je	novcop_failure  ; ax hasn't changed, so novell isn't there
	
	mov	ax,1		; success !
	jmp	novcop_exit
	
novcop_failure:
	mov	ax,0
novcop_exit:	
	pop	di
	pop	si
	pop	bp
	ret
	
_novell_copy ENDP

	PUBLIC	_call_novell
_call_novell	PROC NEAR
	
	push	bp
	mov	bp,sp
	push	es	
	push	si
	push	di

	mov	ah,8[bp]
	mov	al,0ffh
	push	ds
	pop	es
	mov	si,4[bp]
	mov	di,6[bp]
	int	21h

	cmp	al,0
	jne	call_nov_err
	jc	call_nov_err

	mov	ax,0	
	jmp	call_nov_exit

call_nov_err:
	mov	ah,0 ;; clear ah, BUT allow all ret' values in al 
call_nov_exit:	
	pop	di
	pop	si
	pop	es
	pop	bp
	ret

_call_novell	ENDP

	PUBLIC	_nov_station
_nov_station	PROC	NEAR

	push	bp
	mov	bp,sp
	push	si
	
	mov	ax,0eeffh
	int	21h	
	cmp	ax,0ee00h
	je	ns_err
	
	mov	si,4[bp]
	mov	[si],cx
	mov	2[si],bx
	mov	4[si],ax
	mov	ax,0
	jmp	ns_exit

ns_err:
	mov	ax,-1

ns_exit:
	pop	si
	pop	bp
	ret	

_nov_station	ENDP

	public	_nov_connection
_nov_connection	PROC NEAR

	push	es
	push	si

if 0
	mov	ax,0
	mov	es,ax
	mov	si,0
	mov	ax,0ef03h
	int	21h
	
	mov	ax,es
	cmp	ax,0
	jne	nc_ok
	cmp	si,0
	jne	nc_ok
	mov	ax,-1
	jmp	nc_exit	

nc_ok:
	mov	al,es:23[si]
	mov	ah,0
endif

	mov	ax,0dc00h
	int	21h
	jc	nc_err
	sub	ah,ah
	jmp	nc_exit

nc_err:
	mov	al,-1;	

nc_exit:
	pop	si
	pop	es
	ret

_nov_connection	ENDP

_TEXT	ENDS
	END

⌨️ 快捷键说明

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