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

wirehaze git hosting

MZ is back!
[MS-DOS.git] / v4.0 / src / MAPPER / CLOSE.ASM
1 ;\ f\e0
2 page 80,132
3
4 title CP/DOS DosClose mapper * * *
5
6 dosxxx segment byte public 'dos'
7 assume cs:dosxxx,ds:nothing,es:nothing,ss:nothing
8 ;
9 ; ************************************************************************* *
10 ; *
11 ; * MODULE: DosClose
12 ; *
13 ; * FUNCTION: This module will close a file or a device.
14 ; *
15 ; * CALLING SEQUENCE:
16 ; *
17 ; * PUSH WORD FileHandle ; File Handle or device handle
18 ; * CALL DosClose
19 ; *
20 ; * RETURN SEQUENCE:
21 ; *
22 ; * IF ERROR (AX not = 0)
23 ; *
24 ; * AX = Error Code:
25 ; *
26 ; * o Invalid file handle
27 ; *
28 ; *
29 ; * MODULES CALLED: DOS int 21H function 3EH
30 ; *
31 ; *
32 ; *************************************************************************
33
34 public DosClose
35 .sall
36 .xlist
37 include macros.inc
38 .list
39
40 str struc
41 old_bp dw ?
42 return dd ?
43 FileHandle dw ? ; file or device handle
44 str ends
45
46
47 DosClose proc far
48 Enter DosClose ; push registers
49
50 ; Only files are closed. Devices are not closed, since OPEN creates
51 ; a dummy device handle without actually openning the device.
52
53 mov bx,[bp].FileHandle ; load the handle
54 mov ax,bx ; check for device handle
55 neg ax ; if device handle, return
56 jns GoodExit ; do not close the device
57
58 FileCloseRequest:
59 mov ax,03e00h ; load opcode
60 int 21h ; close the file
61 jc ErrorExit ; return if error
62
63 GoodExit:
64 sub ax,ax ; else, set good return code
65
66 ErrorExit:
67 mexit ; pop registers
68 ret size str - 6 ; return
69
70 DosClose endp
71
72 dosxxx ends
73
74 end