1 ; SCCSID = @(#)cpmio.asm 1.1 85/04/10
2 TITLE CPMIO
- device IO for MSDOS
5 ; Standard device IO for MSDOS (first 12 function calls)
15 ; Old style CP/M 1-12 system calls to talk to reserved devices
17 ; $Std_Con_Input_No_Echo
18 ; $Std_Con_String_Output
19 ; $Std_Con_String_Input
27 ; A000 version 4.00 - Jan 1988
28 ; A002 PTM -- dir >lpt3 hangs
40 CODE SEGMENT BYTE PUBLIC 'CODE'
41 ASSUME
SS:DOSGROUP
,CS:DOSGROUP
47 include doscntry
.inc ;AN000 2/12/KK
55 ; The following routines form the console I/O group (funcs 1,2,6,7,8,9,10,11).
56 ; They assume ES and DS NOTHING, while not strictly correct, this forces data
57 ; references to be SS or CS relative which is desired.
64 EXTRN EscChar
:BYTE ; lead byte for function keys
65 EXTRN CanChar
:BYTE ; Cancel character
66 EXTRN OUTCHA
:NEAR ;AN000 char out with status check 2/11/KK
67 i_need Printer_Flag
,BYTE
70 i_need Packet_Temp
,WORD ; temporary packet used by readtime
72 i_need InterChar
,BYTE ;AN000;interim char flag ( 0 = regular char)
73 i_need InterCon
,BYTE ;AN000;console flag ( 1 = in interim mode )
74 i_need SaveCurFlg
,BYTE ;AN000;console out ( 1 = print and do not advance)
75 i_need COUNTRY_CDPG
,byte ;AN000; 2/12/KK
76 i_need TEMP_VAR
,WORD ;AN000; 2/12/KK
77 i_need DOS34_FLAG
,WORD ;AN000; 2/12/KK
84 ;-------------------------------- Start of Korean Support 2/11/KK
85 procedure $STD_CON_INPUT_NO_ECHO
,NEAR ;System call 8 ;AN000;
86 ASSUME
DS:NOTHING
,ES:NOTHING
;AN000;
89 invoke INTER_CON_INPUT_NO_ECHO
;AN000;
90 transfer InterApRet
; go to return fuction ;AN000;
92 EndProc $STD_CON_INPUT_NO_ECHO
;AN000;
94 procedure INTER_CON_INPUT_NO_ECHO
,NEAR ;AN000;
95 ASSUME
DS:NOTHING
,ES:NOTHING
;AN000;
96 ;-----------------------------------End of Korean Support 2/11/KK
101 ; Same as $STD_CON_INPUT_NO_ECHO but uses interim character read from
105 ; Zero flag SET if interim character, RESET otherwise
114 ; Input character from console, no echo
118 procedure $STD_CON_INPUT_NO_ECHO
,NEAR ;System call 8
119 ASSUME
DS:NOTHING
,ES:NOTHING
127 ;*************************************************************************
128 cmp [Printer_Flag
],0 ; is printer idle?
130 mov ah,5 ; get input status with system wait
133 ;**************************************************************************
137 ;;; 7/15/86 update the date in the idle loop
138 ;;; Dec 19, 1986 D.C.L. changed following CMP to Byte Ptr from Word Ptr
139 ;;;; to shorten loop in consideration of the PC Convertible
141 CMP byte ptr [DATE_FLAG
],-1 ; date is updated may be every
142 JNZ NoUpdate
; 65535 x ? ms if no one calls
144 PUSH BX ; following is tricky,
145 PUSH CX ; it may be called by critical handler
146 PUSH DX ; at that time, DEVCALL is used by
147 ; other's READ or WRITE
148 PUSH DS ; save DS = SFT's sgement
149 PUSH CS ; READTIME must use DS=CS
152 MOV AX,0 ; therefore, we save DEVCALL
153 CALL Save_Restore_Packet
; save DEVCALL packet
154 invoke READTIME
; readtime
156 CALL Save_Restore_Packet
; restore DEVCALL packet
158 PUSH BX ; the follwing code is to
159 MOV BX,OFFSET DOSGROUP
:DATE_FLAG
160 ADD BX,2 ; check the TAG
161 CMP word ptr CS:[BX],22642
163 invoke DOSINIT
; should never come here
175 ;;; 7/15/86 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
183 MOV BYTE PTR [SCAN_FLAG
],0
184 CMP AL,0 ; extended code ( AL )
186 MOV BYTE PTR [SCAN_FLAG
],1 ; set this flag for ALT_Q key
191 cmp cs:[InterChar
],1 ;AN000; set the zero flag if the character3/31/KK ;AN000;
195 EndProc INTER_CON_INPUT_NO_ECHO
;AN000; ;2/11/KK ;AN000;
197 EndProc $STD_CON_INPUT_NO_ECHO
203 ; DS:DX Point to output string '$' terminated
205 ; Print the string on the console device
209 procedure $STD_CON_STRING_OUTPUT
,NEAR ;System call 9
210 ASSUME
DS:NOTHING
,ES:NOTHING
216 invoke TESTKANJ
;AN000; 2/11/KK ;AN000;
217 jz SBCS00
;AN000; 2/11/KK ;AN000;
218 invoke OUTT
;AN000; 2/11/KK ;AN000;
219 LODSB ;AN000; 2/11/KK ;AN000;
220 JMP NEXT_STR1
;AN000; 2/11/KK ;AN000;
221 SBCS00: ;AN000; 2/11/KK ;AN000;
229 EndProc $STD_CON_STRING_OUTPUT
232 include kstrin
.asm
;AN000;
241 ; else DL is output character
243 ; Input or output raw character from console, no echo
247 procedure $RAW_CON_IO
,NEAR ; System call 6
248 ASSUME
DS:NOTHING
,ES:NOTHING
255 LES DI,DWORD PTR [user_SP
] ; Get pointer to register save area
260 push word ptr [Intercon
] ;AN000;
261 mov [Intercon
],0 ;AN000; disable interim characters
267 pop word ptr [InterCon
] ;AN000; restore interim flag
270 OR BYTE PTR ES:[DI.user_F
],40H
; Set user's zero flag
275 AND BYTE PTR ES:[DI.user_F
],0FFH-40H
; Reset user's zero flag
278 invoke IOFUNC
;AN000; get the character
279 pop word ptr [InterCon
] ;AN000;
281 ENDIF
;AN000; ;AN000;
289 ; Input raw character from console, no echo
293 entry $RAW_CON_INPUT
; System call 7
310 cmp [InterChar
],1 ;AN000; 2/11/KK
312 ; Sets the application zero flag depending on the 2/11/KK
313 ; zero flag upon entry to this routine. Then returns 2/11/KK
314 ; from system call. 2/11/KK
316 entry InterApRet
;AN000; 2/11/KK ;AN000;
317 pushf ;AN000; 3/16/KK
318 push ds ;AN000; 3/16/KK
319 push bx ;AN000; 3/16/KK
320 Context
DS ;AN000; 3/16/KK
321 MOV BX,offset DOSGROUP
:COUNTRY_CDPG
.ccDosCodePage
322 cmp word ptr [bx],934 ;AN000; 3/16/KK korean code page ?
323 pop bx ;AN000; 3/16/KK
324 pop ds ;AN000; 3/16/KK
325 je do_koren
;AN000; 3/16/KK
327 return
;AN000; 3/16/KK
328 do_koren: ;AN000; 3/16/KK
330 LES DI,DWORD PTR [user_SP
] ;AN000; Get pointer to register save area KK
331 jnz sj0
;AN000; 2/11/KK
332 OR BYTE PTR ES:[DI.user_F
],40H
;AN000; Set user's zero flag 2/11/KK
333 return
;AN000; 2/11/KK
335 AND BYTE PTR ES:[DI.user_F
],0FFH-40H
;AN000; Reset user's zero flag 2/KK
339 ; Output the character in AL to stdout
352 ; If we are a network handle OR if we are not a local device then go do the
353 ; output the hard way.
356 AND BX,sf_isNet
+ devid_device
360 TEST [SaveCurFlg
],01H ;AN000; print but no cursor adv?
361 JNZ RAWNORM
;AN000; 2/11/KK
364 ; TEST BX,sf_isnet ; output to NET?
365 ; JNZ RAWNORM ; if so, do normally
366 ; TEST BX,devid_device ; output to file?
367 ; JZ RAWNORM ; if so, do normally
370 LDS BX,[SI.sf_devptr
] ; output to special?
371 TEST BYTE PTR [BX+SDEVATT
],ISSPEC
373 JZ RAWNORM
; if not, do normally
374 INT int_fastcon
; quickly output the char
385 ; Output the character in AL to handle in BX
396 OR [DOS34_FLAG
],CTRL_BREAK_FLAG
;AN002; set control break
397 invoke DSKSTATCHK
;AN002; check control break
405 CLC ; Clear carry indicating successful
410 ; AX=0 save the DEVCALL request packet
411 ; =1 restore the DEVCALL request packet
413 ; save or restore the DEVCALL packet
417 procedure Save_Restore_Packet
,NEAR
418 ASSUME
DS:NOTHING
,ES:NOTHING
424 CMP AX,0 ; save packet
427 MOV SI,OFFSET DOSGROUP
:Packet_Temp
;sourec
428 MOV DI,OFFSET DOSGROUP
:DEVCALL
;destination
431 MOV DI,OFFSET DOSGROUP
:Packet_Temp
;destination
432 MOV SI,OFFSET DOSGROUP
:DEVCALL
;source
434 MOV AX,CS ; set DS,ES to DOSGROUP
437 MOV CX,11 ; 11 words to move
445 EndProc Save_Restore_Packet