]>
wirehaze git hosting - MS-DOS.git/blob - v2.0/source/DEV.ASM
2 ; Device call routines for MSDOS
11 CODE SEGMENT BYTE PUBLIC 'CODE'
12 ASSUME
SS:DOSGROUP
,CS:DOSGROUP
21 TITLE DEV
- Device
call routines
32 i_need NullDevPt
,DWORD
33 i_need CallDevAd
,DWORD
44 SUBTTL IOFUNC
-- DO FUNCTION
1-12 I
/O
47 ASSUME
DS:NOTHING
,ES:NOTHING
51 ASSUME
DS:NOTHING
,ES:NOTHING
61 ; AL = character if output
63 ; Perform indicated I/O to device or file
65 ; AL is character if input
67 ; zero set if not ready
68 ; zero reset if ready (character in AL for input status)
71 ; Gets character but restores fcb_RR field
74 ; Gets character advances fcb_RR field
78 ; AX altered, all other registers preserved
80 MOV WORD PTR [IOXAD
+2],SS
81 MOV WORD PTR [IOXAD
],OFFSET DOSGROUP
:DEVIOBUF
82 MOV WORD PTR [IOSCNT
],1
83 MOV WORD PTR [DEVIOBUF
],AX
86 TEST [SI.fcb_DEVID
],080H
99 MOV [IOCALL
.REQSTAT
],BX
100 MOV BYTE PTR [IOMED
],BL
102 MOV BX,OFFSET DOSGROUP
:IOCALL
104 MOV CX,(DEVRD
SHL 8) OR DRDWRHL
107 MOV CX,(DEVRDND
SHL 8) OR DRDNDHL
110 MOV CX,(DEVWRT
SHL 8) OR DRDWRHL
113 MOV CX,(DEVOST
SHL 8) OR DSTATHL
117 MOV CX,(DEVIFL
SHL 8) OR DFLSHL
121 MOV [IOCALL
.REQLEN
],CL
122 MOV [IOCALL
.REQFUNC
],CH
127 MOV DI,[IOCALL
.REQSTAT
]
134 ;Know user must have wanted ignore. Make sure device shows ready so
135 ;that DOS doesn't get caught in a status loop when user simply wants
136 ;to ignore the error.
137 AND BYTE PTR [IOCALL
.REQSTAT
+1], NOT (STBUI
SHR 8)
144 MOV AL,BYTE PTR [IORCHR
]
147 DNODRD: MOV AH,BYTE PTR [IOCALL
.REQSTAT
+1]
148 NOT AH ; Zero = busy, not zero = ready
153 MOV AX,WORD PTR [DEVIOBUF
]
168 return
; NON ZERO FLAG FOR OUTPUT STATUS
171 PUSH WORD PTR [SI.fcb_RR
] ; Save position
172 PUSH WORD PTR [SI.fcb_RR
+2]
174 POP WORD PTR [SI.fcb_RR
+2] ; Restore position
175 POP WORD PTR [SI.fcb_RR
]
182 CALL RESTXADDR
; If you change this into a jmp don't come
183 return
; crying to me when things don't work ARR
193 MOV AL,[DEVIOBUF
] ; Get byte from trans addr
195 MOV AL,1
AH ; ^Z if EOF
199 POP WORD PTR [CALLSCNT
] ; Return address
201 PUSH WORD PTR [DMAADD
] ; Save Disk trans addr
202 PUSH WORD PTR [DMAADD
+2]
207 MOV CX,WORD PTR [IOXAD
+2]
208 MOV WORD PTR [DMAADD
+2],CX
209 MOV CX,WORD PTR [IOXAD
]
210 MOV WORD PTR [DMAADD
],CX ; Set byte trans addr
211 MOV CX,[IOSCNT
] ; ioscnt specifies length of buffer
214 MOV [SI.fcb_RECSIZ
],1 ; One byte per record
215 MOV DX,SI ; FCB to DS:DX
217 JMP SHORT RESTRET
; RETURN ADDRESS
220 POP WORD PTR [CALLSCNT
] ; Return address
221 POP WORD PTR [DMAADD
+2] ; Restore Disk trans addr
222 POP WORD PTR [DMAADD
]
224 RESTRET:JMP WORD PTR [CALLSCNT
] ; Return address
227 SUBTTL DEVIOCALL
, DEVIOCALL2
- CALL A DEVICE
229 procedure DEVIOCALL
,NEAR
230 ASSUME
DS:NOTHING
,ES:NOTHING
233 ; DS:SI Points to device FCB
234 ; ES:BX Points to request data
239 ; DS:SI,AX destroyed, others preserved
241 LDS SI,DWORD PTR [SI.fcb_FIRCLUS
]
244 ; As above only DS:SI points to device header on entry, and DS:SI is preserved
245 MOV AX,[SI.SDEVSTRAT
]
246 MOV WORD PTR [CALLDEVAD
],AX
247 MOV WORD PTR [CALLDEVAD
+2],DS
248 CALL DWORD PTR [CALLDEVAD
]
250 MOV WORD PTR [CALLDEVAD
],AX
251 CALL DWORD PTR [CALLDEVAD
]
255 SUBTTL DEVNAME
- LOOK FOR NAME OF DEVICE
257 procedure DEVNAME
,NEAR
258 ASSUME
DS:DOSGROUP
,ES:DOSGROUP
264 ; Determine if file is in list of I/O drivers
266 ; Carry set if name not found
269 ; BH = Bit 7,6 = 1, bit 5 = 0 (cooked mode)
270 ; bits 0-4 set from low byte of attribute word
271 ; DEVPT = DWORD pointer to Device header of device
272 ; Registers BX destroyed
279 PUSH WORD PTR [NAME1
]
286 TEST BYTE PTR [ATTRIB
],attr_volume_id
; If looking for VOL id don't find devs
288 MOV SI,OFFSET DOSGROUP
:NULDEV
291 TEST [SI.SDEVATT
],DEVTYP
292 JZ SKIPDEV
; Skip block devices
295 MOV DI,OFFSET DOSGROUP
:NAME1
296 MOV CX,4 ; All devices are 8 letters
297 REPE CMPSW ; Check for name in list
301 LDS SI,DWORD PTR [SI] ; Get address of next device
302 CMP SI,-1 ; At end of list?
304 RET31: STC ; Not found
320 MOV WORD PTR [DEVPT
+2],DS ; Save pointer to device
321 MOV BH,BYTE PTR [SI.SDEVATT
]
323 AND BH,NOT 020H ;Clears Carry
324 MOV WORD PTR [DEVPT
],SI
329 ASSUME
DS:DOSGROUP
,ES:NOTHING
332 ; AL = Logical unit number (A = 0)
334 ; Find Drive Parameter Block
336 ; ES:BP points to DPB
338 ; Carry set if unit number bad
339 ; No other registers altered
341 LES BP,[DPBHEAD
] ; Just in case drive isn't valid
342 AND AL,3FH
; Mask out dirty and device bits
343 CMP AL,BYTE PTR [NUMIO
]
345 JC GOTDPB
; Get drive A
347 CMP AL,ES:[BP.dpb_drive
]
348 JZ GOTDPB
; Carry is clear if jump executed
349 LES BP,ES:[BP.dpb_next_dpb
]
352 MOV WORD PTR [THISDPB
],BP
353 MOV WORD PTR [THISDPB
+2],ES
357 SUBTTL SETREAD
, SETWRITE
-- SET UP HEADER BLOCK
359 procedure SETREAD
,NEAR
360 ASSUME
DS:NOTHING
,ES:NOTHING
363 ; DS:BX = Transfer Address
365 ; DX = Starting Record
369 ; Set up the device call header at DEVCALL
371 ; ES:BX Points to DEVCALL
372 ; No other registers effected
382 MOV DI,OFFSET DOSGROUP
:DEVCALL
391 ADD DI,8 ; Skip link fields
400 STOSW ; Transfer addr
404 XCHG AX,DX ; AX=Real DX, DX=real CX, CX=real AX
409 MOV BX,OFFSET DOSGROUP
:DEVCALL
413 ASSUME
DS:NOTHING
,ES:NOTHING
416 ; DS:BX = Transfer Address
418 ; DX = Starting Record
422 ; Set up the device call header at DEVCALL
424 ; ES:BX Points to DEVCALL
425 ; No other registers effected
432 JMP SHORT SETCALLHEAD