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

📄 cio.a86

📁 一个dos操作系统DRDOS的源码
💻 A86
📖 第 1 页 / 共 3 页
字号:
;    File              : $CIO.A86$
;
;    Description       :
;
;    Original Author   : DIGITAL RESEARCH
;
;    Last Edited By    : $CALDERA$
;
;-----------------------------------------------------------------------;
;    Copyright Work of Caldera, Inc. All Rights Reserved.
;      
;    THIS WORK IS A COPYRIGHT WORK AND CONTAINS CONFIDENTIAL,
;    PROPRIETARY AND TRADE SECRET INFORMATION OF CALDERA, INC.
;    ACCESS TO THIS WORK IS RESTRICTED TO (I) CALDERA, INC. EMPLOYEES
;    WHO HAVE A NEED TO KNOW TO PERFORM TASKS WITHIN THE SCOPE OF
;    THEIR ASSIGNMENTS AND (II) ENTITIES OTHER THAN CALDERA, INC. WHO
;    HAVE ACCEPTED THE CALDERA OPENDOS SOURCE LICENSE OR OTHER CALDERA LICENSE
;    AGREEMENTS. EXCEPT UNDER THE EXPRESS TERMS OF THE CALDERA LICENSE
;    AGREEMENT NO PART OF THIS WORK MAY BE USED, PRACTICED, PERFORMED,
;    COPIED, DISTRIBUTED, REVISED, MODIFIED, TRANSLATED, ABRIDGED,
;    CONDENSED, EXPANDED, COLLECTED, COMPILED, LINKED, RECAST,
;    TRANSFORMED OR ADAPTED WITHOUT THE PRIOR WRITTEN CONSENT OF
;    CALDERA, INC. ANY USE OR EXPLOITATION OF THIS WORK WITHOUT
;    AUTHORIZATION COULD SUBJECT THE PERPETRATOR TO CRIMINAL AND
;    CIVIL LIABILITY.
;-----------------------------------------------------------------------;
;
;    *** Current Edit History ***
;    *** End of Current Edit History ***
;    $Log: $
;    CIO.A86 1.20 94/12/01 10:05:21
;    Made cooked_write and is_device aware of FCB writes;    
;    CIO.A86 1.19 94/06/28 12:21:07
;    Fix last_key_ext bug
;    CIO.A86 1.18 94/05/12 14:06:22
;    The routine cooked_status now sets a flag last_key_ext if the keycode is 0.
;    On entry, it checks this flag to see if the last one was 0, and if so does
;    not do the checks for the control keys. In this way, Alt-R and Alt-Q can
;    be distinguished from Ctrl-S and Ctrl-P.
;    CIO.A86 1.17 93/12/21 17:58:15
;    Preserve BX round clock read
;    Update char_error so DS:SI -> device driver header itself
;    CIO.A86 1.10 93/05/06 19:28:03
;    Move int 23/28 support to CIO.
;    Read the clock in idle_dev, not int 28 loop.
;    CIO.A86 1.9 93/05/05 23:30:44
;    int 2A/84 is now only generated on input-and-wait functions
;    CIO.A86 1.8 93/03/25 15:05:56
;    tweak console block output
;    ENDLOG
;
;	This module contains all the Character I/O functions used by PCMODE
;
; 12 Nov 87 Disable Control-Break when the Console Output mode is RAW
; 24 Feb 88 Display Control characters correctly. ie "^X"
; 23 May 88 Support ^S to Pause screen output.
; 25 May 88 Support Control-P for Cooked_Write and remove Kanji Character
;           check.
; 26 May 88 Check for CTLC on CON_DEV when character input is redirected.
;           Correctly detect EOF on redirected input.
; 17 Aug 88 Call PRN device with Open/Close on ^P
; 30 Aug 88 Jump to correct exit when Open/Close is not supported by a 
;           device driver for ^P.
; 14 Sep 88 Break checking should only be carried out when the INDOS_FLAG
;           is 1. (Novell and Cntrl-C).
; 03 Sep 88 Return the character output by INT21/04,05,06 in AL.
; 10 Nov 88 Preserve ES when calling any Device Driver (Revalation DEVDRVR)
; 15 Dec 88 Check STDERR for Control-C if it is a Device.
; 15 Mar 89 Check for CTLC during Cooked Write.
; 16 Mar 89 Explicitly allow INT 28 during char reads (SmartNotes bug)
; 25 Apr 89 Execute break_check after getting the console status INT21/0B
;  2 May 89 Save Device driver STRAT and INT address's on the stack
; 10 May 89 Now check keyboard more often during cooked write
; 25 May 89 Move INT28 flag to PCMIF.PCM
;  6 Sep 89 Enter/Exit critical region round device request
; 26 Oct 89 saving some bytes again...
; 25 Jan 90 Insert IDLE Detection Code
; 29 Jan 90 Int 2A critical section support added to device_callf
;  7 Mar 90 Convert to register preserved function calls
; 27 Mar 90 cooked_write checks STD_OUT for ctl-s ctl-p etc (STD_IN may
;           have been redirected)
; 29 Mar 90 preserve BX round device_callf (3+Share CLOCK$ bug)
; 12 Jun 90 get_doshndl parameter BX not AX
; 15 Oct 90 Added support for Return Interim Character flag (see PSP_RIC).
; 26 Oct 90 handle PSP=0 (ie. FCB device I/O)
;  1 mar 91 break_check now goes to con_device, not STDERR
; 17 jun 91 ij	fix to cooked_out to avoid status checks if STDOUT redirected

	include	pcmode.equ
	include i:driver.equ
	include	i:reqhdr.equ
	include	i:msdos.equ
	include	i:fdos.equ
	include	i:psp.def
	include	i:mserror.equ
	include	i:char.def
	include	i:redir.equ
	include	i:doshndl.def

CIO_CTLP	equ	0000$0001b	; Printer Echo State
CIO_HANDLE	equ	0000$0010b	; use handle rather than Int 29
CIO_RAW		equ	0000$0100b	; no "cooked_status" checks

CHECK_EVERY	equ	80		; check keyboard every "n" characters

PCM_CODE	CSEG	BYTE
	extrn	char_error:near
	extrn	device_driver:near
	extrn	dos_entry:near
	extrn	get_dseg:near
	extrn	ifn2dhndl:near
	extrn	int21_entry:near
	extrn	int21_func:near
	extrn	read_line:near
	extrn	ReadTimeAndDate:near
	extrn	reload_registers:near

;	*****************************
;	***    DOS Function 01    ***
;	***  Keybd Input W/Echo   ***
;	*****************************
;
	Public	func01
func01:
;
; Entry:
;	AH  ==	01h
; Exit:
;	AL  ==	char
;
	call	func08			; Read 1 character from Standard Input
					; and check for Control-C
	xchg	ax,dx			; echo using common code

;	*****************************
;	***    DOS Function 02    ***
;	***     Display Output    ***
;	*****************************
;
	Public	func02
func02:
;
; Entry:
;	AH  ==	02h
;	DL  ==	char to display
;
	push	dx			; char on stack
	push ss ! pop es
	mov	si,sp			; ES:DX -> character
	mov	cx,1
	call	stdout_cooked_write	; write character
	pop	ax			; recover char
	ret

;	*****************************
;	***    DOS Function 03    ***
;	***    Auxiliary Input    ***
;	*****************************
;
	Public	func03
func03:
;
; Entry:
;	AH  ==	03h
; Exit:
;	AL  ==	Char
;
	mov	bx,STDAUX		; Read 1 character from Standard AUX
f03_10:
	jmp	raw_read

;	*****************************
;	***    DOS Function 04    ***
;	***    Auxiliary Output   ***
;	*****************************
;
	Public	func04
func04:
;
; Entry:
;	AH  ==	04h
;	DL  ==	Character to output
;
	mov	bx,STDAUX		; write the character passed in DL
	jmps	f456common		;  to the STDAUX Handle

;	*****************************
;	***    DOS Function 05    ***
;	***    Printer Output     ***
;	*****************************
;
	Public	func05
func05:
;
; Entry:
;	AH  ==	05h
;	DL  ==	character to output to printer
;
	mov	bx,STDPRN		; write the character passed in DL
;	jmp	f456common		;  to the STDPRN Handle

f456common:
	xchg	ax,dx			; character in AL
;	jmp	hndl_write

hndl_write:
;----------
; On Entry:
;	AL = character to write
;	BX = handle
; On Exit:
;	AL preserved
;
	call	is_device		; Does this handle refer to a device
	 jc	hndl_w10
	test	es:DH_ATTRIB[si],DA_SPECIAL
	 jz	hndl_w10		; Fast Console Output Using Int 29?
	int	29h			; This device supports FAST console
	ret				;  output so write this using Int29

hndl_w10:
	push	ax			; character on stack
	mov	dx,sp			; SS:DX -> char
	mov	cx,1			; do a single character
	 jc	hndl_w20		; was it a file ?
	call	device_write		; send to device driver
	jmps	hndl_w30
hndl_w20:
	push ss ! pop es		; ES:DX -> character
	mov	ah,MS_X_WRITE		; otherwise call the FDOS to do all
	call	dos_entry		;  the hard work
hndl_w30:
	pop	ax
	ret


;	*****************************
;	***    DOS Function 06    ***
;	***   Direct Console I/O  ***
;	*****************************
;
	Public	func06
func06:
;
; Entry:
;	AH  ==	06h
;	DL  ==	0FFh or Output char
; Exit:
;	AL  ==	Input char, if DL was 0FFh on input
;
	mov	bx,STDOUT			; Assume output DL to console
	cmp	dl,0FFH				; or is it input ?
	 jne	f456common
	dec	bx
;	mov	bx,STDIN			; is there a character ready
	call	char_check			;  to be input
	 jz	func07
	mov	ax,RHS_IC			; set AL=0 and also set ZF on
	jmps	funcICexit			;  exit as incomplete char


;	*****************************
;	***    DOS Function 07    ***
;	***   Raw Input w/o echo  ***
;	*****************************
;
	Public	func07
func07:
;
; Entry:
;	AH  ==	07h
; Exit:
;	AL  ==	character
;
	mov	bx,STDIN
	call	raw_read			; extra status call made
	jmps	funcICexit			; set incomplete char
	
;	*****************************
;	***    DOS Function 08    ***
;	***    Input w/o echo     ***
;	*****************************
;
	Public	func08
func08:
;
; Entry:
;	AH  ==	08h
; Exit:
;	AL  ==	character
;
	mov	bx,STDIN		; Read 1 character from Standard Input
	call	cooked_read
funcICexit:
; exit point for incomplete character support
; On Entry:
;	AL = character
;	AH = request header status (RHS_IC as on return from device driver)
; On Exit:
;	AL = character
;	dos_FLAGS ZF set if incomplete character
;
	les	di,int21regs_ptr		; point to callers registers
	and	es:reg_FLAGS[di],not ZERO_FLAG	; clear ZF
	test	ah,RHS_IC/256			; is it an incomplete char ?
	 jz	funcIC10			;  no - exit
	or	es:reg_FLAGS[di],ZERO_FLAG	;  yes - set ZF
funcIC10:
	ret

;	*****************************
;	***    DOS Function 09    ***
;	***     Print String      ***
;	*****************************
;
	Public	func09
func09:
;
; Entry:
;	AH  ==	09h
;    DS:DX  ==	address of character string
;

	mov	al,'$'			; it's terminated with a '$'
	mov	di,dx			; locate the end of the string 
	mov	cx,0FFFFh		; and calculate its length
	repnz	scasb
	not	cx
	dec	cx			; CX is the character count
	mov	si,dx
	call	stdout_cooked_write	; ES:SI -> character buffer
    mov al,'$'          
    ret


;	*****************************
;	***    DOS Function 0A    ***
;	***      Read String      ***
;	*****************************
;
	Public	func0A
func0A:
;
; Entry:
;	AH  ==	0Ah
;    DS:DX  ==	pointer to input buffer
;
	mov	bx,STDIN		; Read the editted line from STDIN
	mov	cx,STDOUT		; and display the results on STDOUT
	jmp	read_line		; Read the Line

;	*****************************
;	***    DOS Function 0B    ***
;	***    Console Status     ***
;	*****************************
;
	Public	func0B

⌨️ 快捷键说明

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