]> wirehaze git hosting - MS-DOS.git/blob - v4.0/src/DOS/CPMIO.ASM

wirehaze git hosting

MZ is back!
[MS-DOS.git] / v4.0 / src / DOS / CPMIO.ASM
1 ; SCCSID = @(#)cpmio.asm 1.1 85/04/10
2 TITLE CPMIO - device IO for MSDOS
3 NAME CPMIO
4 ;
5 ; Standard device IO for MSDOS (first 12 function calls)
6 ;
7
8 .xlist
9 .xcref
10 include dosseg.asm
11 .cref
12 .list
13
14 ;
15 ; Old style CP/M 1-12 system calls to talk to reserved devices
16 ;
17 ; $Std_Con_Input_No_Echo
18 ; $Std_Con_String_Output
19 ; $Std_Con_String_Input
20 ; $RawConIO
21 ; $RawConInput
22 ; RAWOUT
23 ; RAWOUT2
24 ;
25 ; Revision history:
26 ;
27 ; A000 version 4.00 - Jan 1988
28 ; A002 PTM -- dir >lpt3 hangs
29 ;
30 ;
31 ;
32 ;
33 ;
34 ;
35 ;
36 ;
37 ;
38 ;
39
40 CODE SEGMENT BYTE PUBLIC 'CODE'
41 ASSUME SS:DOSGROUP,CS:DOSGROUP
42
43 .xcref
44 .xlist
45 INCLUDE DOSSYM.INC
46 INCLUDE DEVSYM.INC
47 include doscntry.inc ;AN000 2/12/KK
48 .list
49 .cref
50
51 IFNDEF KANJI
52 KANJI EQU 0 ;FALSE
53 ENDIF
54
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.
58
59 i_need CARPOS,BYTE
60 i_need STARTPOS,BYTE
61 i_need INBUF,128
62 i_need INSMODE,BYTE
63 i_need user_SP,WORD
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
68 i_need SCAN_FLAG,BYTE
69 i_need DATE_FLAG,WORD
70 i_need Packet_Temp,WORD ; temporary packet used by readtime
71 i_need DEVCALL,DWORD
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
78
79
80
81 Break
82 IF DBCS ;AN000;
83
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;
87
88 StdCILop: ;AN000;
89 invoke INTER_CON_INPUT_NO_ECHO ;AN000;
90 transfer InterApRet ; go to return fuction ;AN000;
91
92 EndProc $STD_CON_INPUT_NO_ECHO ;AN000;
93
94 procedure INTER_CON_INPUT_NO_ECHO,NEAR ;AN000;
95 ASSUME DS:NOTHING,ES:NOTHING ;AN000;
96 ;-----------------------------------End of Korean Support 2/11/KK
97
98 ; Inputs:
99 ; None
100 ; Function:
101 ; Same as $STD_CON_INPUT_NO_ECHO but uses interim character read from
102 ; the device.
103 ; Returns:
104 ; AL = character
105 ; Zero flag SET if interim character, RESET otherwise
106
107 ELSE ;AN000;
108
109
110 ;
111 ; Inputs:
112 ; None
113 ; Function:
114 ; Input character from console, no echo
115 ; Returns:
116 ; AL = character
117
118 procedure $STD_CON_INPUT_NO_ECHO,NEAR ;System call 8
119 ASSUME DS:NOTHING,ES:NOTHING
120
121 ENDIF
122 PUSH DS
123 PUSH SI
124 INTEST:
125 invoke STATCHK
126 JNZ Get
127 ;*************************************************************************
128 cmp [Printer_Flag],0 ; is printer idle?
129 jnz no_sys_wait
130 mov ah,5 ; get input status with system wait
131 invoke IOFUNC
132 no_sys_wait:
133 ;**************************************************************************
134 MOV AH,84h
135 INT int_IBM
136
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
140
141 CMP byte ptr [DATE_FLAG],-1 ; date is updated may be every
142 JNZ NoUpdate ; 65535 x ? ms if no one calls
143 PUSH AX
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
150 POP DS
151
152 MOV AX,0 ; therefore, we save DEVCALL
153 CALL Save_Restore_Packet ; save DEVCALL packet
154 invoke READTIME ; readtime
155 MOV AX,1
156 CALL Save_Restore_Packet ; restore DEVCALL packet
157
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
162 JZ check_ok
163 invoke DOSINIT ; should never come here
164 check_ok:
165 POP BX
166
167 POP DS ; restore DS
168 POP DX
169 POP CX
170 POP BX
171 POP AX
172 NoUpdate:
173 INC [DATE_FLAG]
174
175 ;;; 7/15/86 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
176 JMP Intest
177 Get:
178 XOR AH,AH
179 invoke IOFUNC
180 POP SI
181 POP DS
182 ;;; 7/15/86
183 MOV BYTE PTR [SCAN_FLAG],0
184 CMP AL,0 ; extended code ( AL )
185 JNZ noscan
186 MOV BYTE PTR [SCAN_FLAG],1 ; set this flag for ALT_Q key
187
188 noscan:
189 ;;; 7/15/86
190 IF DBCS ;AN000;
191 cmp cs:[InterChar],1 ;AN000; set the zero flag if the character3/31/KK ;AN000;
192 ENDIF ;AN000;
193 return
194 IF DBCS ;AN000;
195 EndProc INTER_CON_INPUT_NO_ECHO ;AN000; ;2/11/KK ;AN000;
196 ELSE ;AN000;
197 EndProc $STD_CON_INPUT_NO_ECHO
198 ENDIF ;AN000;
199
200 Break
201
202 ; Inputs:
203 ; DS:DX Point to output string '$' terminated
204 ; Function:
205 ; Print the string on the console device
206 ; Returns:
207 ; None
208
209 procedure $STD_CON_STRING_OUTPUT,NEAR ;System call 9
210 ASSUME DS:NOTHING,ES:NOTHING
211
212 MOV SI,DX
213 STRING_OUT1:
214 LODSB
215 IF DBCS ;AN000;
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;
222 ENDIF ;AN000;
223 CMP AL,'$'
224 retz
225 NEXT_STR1:
226 invoke OUTT
227 JMP STRING_OUT1
228
229 EndProc $STD_CON_STRING_OUTPUT
230
231 IF DBCS ;AN000;
232 include kstrin.asm ;AN000;
233 ELSE ;AN000;
234 include strin.asm
235 ENDIF ;AN000;
236
237 Break
238
239 ; Inputs:
240 ; DL = -1 if input
241 ; else DL is output character
242 ; Function:
243 ; Input or output raw character from console, no echo
244 ; Returns:
245 ; AL = character
246
247 procedure $RAW_CON_IO,NEAR ; System call 6
248 ASSUME DS:NOTHING,ES:NOTHING
249
250 MOV AL,DL
251 CMP AL,-1
252 JZ RAW22 ;AN000;
253 JMP RAWOUT ;AN000;
254 RAW22: ;AN000;
255 LES DI,DWORD PTR [user_SP] ; Get pointer to register save area
256 XOR BX,BX
257 invoke GET_IO_SFT
258 retc
259 IF DBCS ;AN000;
260 push word ptr [Intercon] ;AN000;
261 mov [Intercon],0 ;AN000; disable interim characters
262 ENDIF ;AN000;
263 MOV AH,1
264 invoke IOFUNC
265 JNZ RESFLG
266 IF DBCS ;AN000;
267 pop word ptr [InterCon] ;AN000; restore interim flag
268 ENDIF ;AN000;
269 invoke SPOOLINT
270 OR BYTE PTR ES:[DI.user_F],40H ; Set user's zero flag
271 XOR AL,AL
272 return
273
274 RESFLG:
275 AND BYTE PTR ES:[DI.user_F],0FFH-40H ; Reset user's zero flag
276 IF DBCS ;AN000;
277 XOR AH,AH ;AN000;
278 invoke IOFUNC ;AN000; get the character
279 pop word ptr [InterCon] ;AN000;
280 return ;AN000;
281 ENDIF ;AN000; ;AN000;
282
283 RILP:
284 invoke SPOOLINT
285
286 ; Inputs:
287 ; None
288 ; Function:
289 ; Input raw character from console, no echo
290 ; Returns:
291 ; AL = character
292
293 entry $RAW_CON_INPUT ; System call 7
294
295 PUSH BX
296 XOR BX,BX
297 invoke GET_IO_SFT
298 POP BX
299 retc
300 MOV AH,1
301 invoke IOFUNC
302 JNZ Got
303 MOV AH,84h
304 INT int_IBM
305 JMP RILP
306 Got:
307 XOR AH,AH
308 invoke IOFUNC
309 IF DBCS ;AN000;
310 cmp [InterChar],1 ;AN000; 2/11/KK
311 ; 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
315 ; 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
326 popf ;AN000; 3/16/KK
327 return ;AN000; 3/16/KK
328 do_koren: ;AN000; 3/16/KK
329 popf ;AN000;
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
334 sj0: ;AN000; 2/11/KK
335 AND BYTE PTR ES:[DI.user_F],0FFH-40H ;AN000; Reset user's zero flag 2/KK
336 ENDIF ;AN000;
337 return ;AN000;
338 ;
339 ; Output the character in AL to stdout
340 ;
341 entry RAWOUT
342
343 PUSH BX
344 MOV BX,1
345
346 invoke GET_IO_SFT
347 JC RAWRET1
348
349 MOV BX,[SI.sf_flags]
350
351 ;
352 ; If we are a network handle OR if we are not a local device then go do the
353 ; output the hard way.
354 ;
355
356 AND BX,sf_isNet + devid_device
357 CMP BX,devid_device
358 JNZ RawNorm
359 IF DBCS ;AN000;
360 TEST [SaveCurFlg],01H ;AN000; print but no cursor adv?
361 JNZ RAWNORM ;AN000; 2/11/KK
362 ENDIF ;AN000;
363
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
368
369 PUSH DS
370 LDS BX,[SI.sf_devptr] ; output to special?
371 TEST BYTE PTR [BX+SDEVATT],ISSPEC
372 POP DS
373 JZ RAWNORM ; if not, do normally
374 INT int_fastcon ; quickly output the char
375 RAWRET:
376 CLC
377 RAWRET1:
378 POP BX
379 return
380 RAWNORM:
381 CALL RAWOUT3
382 JMP RAWRET
383
384 ;
385 ; Output the character in AL to handle in BX
386 ;
387 entry RAWOUT2
388
389 invoke GET_IO_SFT
390 retc
391 RAWOUT3:
392 PUSH AX
393 JMP SHORT RAWOSTRT
394 ROLP:
395 invoke SPOOLINT
396 OR [DOS34_FLAG],CTRL_BREAK_FLAG ;AN002; set control break
397 invoke DSKSTATCHK ;AN002; check control break
398 RAWOSTRT:
399 MOV AH,3
400 invoke IOFUNC
401 JZ ROLP
402 POP AX
403 MOV AH,2
404 invoke IOFUNC
405 CLC ; Clear carry indicating successful
406 return
407 EndProc $RAW_CON_IO
408
409 ; Inputs:
410 ; AX=0 save the DEVCALL request packet
411 ; =1 restore the DEVCALL request packet
412 ; Function:
413 ; save or restore the DEVCALL packet
414 ; Returns:
415 ; none
416
417 procedure Save_Restore_Packet,NEAR
418 ASSUME DS:NOTHING,ES:NOTHING
419
420 PUSH DS
421 PUSH ES
422 PUSH SI
423 PUSH DI
424 CMP AX,0 ; save packet
425 JZ save_packet
426 restore_packet:
427 MOV SI,OFFSET DOSGROUP:Packet_Temp ;sourec
428 MOV DI,OFFSET DOSGROUP:DEVCALL ;destination
429 JMP set_seg
430 save_packet:
431 MOV DI,OFFSET DOSGROUP:Packet_Temp ;destination
432 MOV SI,OFFSET DOSGROUP:DEVCALL ;source
433 set_seg:
434 MOV AX,CS ; set DS,ES to DOSGROUP
435 MOV DS,AX
436 MOV ES,AX
437 MOV CX,11 ; 11 words to move
438 REP MOVSW
439
440 POP DI
441 POP SI
442 POP ES
443 POP DS
444 return
445 EndProc Save_Restore_Packet
446
447 CODE ENDS
448 END