summaryrefslogtreecommitdiff
path: root/v4.0/src/MAPPER/CLOSE.ASM
blob: ee7aa4c77bd07a10c0a31f176ee9dca1929261d3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
;0
page 80,132

title CP/DOS  DosClose  mapper   * * *

dosxxx	segment byte public 'dos'
	assume	cs:dosxxx,ds:nothing,es:nothing,ss:nothing
;
; ************************************************************************* *
; *
; *	 MODULE: DosClose
; *
; *	 FUNCTION: This module will close a file or a device.
; *
; *	 CALLING SEQUENCE:
; *
; *		   PUSH  WORD  FileHandle ;  File Handle or device handle
; *		   CALL  DosClose
; *
; *	 RETURN SEQUENCE:
; *
; *		   IF ERROR (AX not = 0)
; *
; *		      AX = Error Code:
; *
; *		      o   Invalid file handle
; *
; *
; *	 MODULES CALLED:  DOS int 21H function 3EH
; *
; *
; *************************************************************************

	public	DosClose
	.sall
	.xlist
	include macros.inc
	.list

str	struc
old_bp	   dw	  ?
return	   dd	  ?
FileHandle dw	  ?	     ; file or device handle
str	ends


DosClose  proc	 far
	Enter	DosClose	       ; push registers

; Only files are closed.  Devices are not closed, since OPEN creates
; a dummy device handle without actually openning the device.

	mov	bx,[bp].FileHandle     ; load the handle
	mov	ax,bx		       ; check for device handle
	neg	ax		       ; if device handle, return
	jns	GoodExit	       ; do not close the device

FileCloseRequest:
	mov	ax,03e00h	       ; load opcode
	int	21h		       ; close the file
	jc	ErrorExit	       ; return if error

GoodExit:
	sub	ax,ax		       ; else, set good return code

ErrorExit:
	mexit			       ; pop registers
	ret	size str - 6	       ; return

DosClose  endp

dosxxx	ends

	end