Chawter
1
I
System Calls
Example:
The following program copies
a
file using the Random
Block Read and Random Block Write function calls. It
speeds the copy by specifying
a
record count equal
to
the
file size and
a
record length
of
1.
With
a
buffer
of
32K
bytes the file is copied quickly, requiring
1
disk access
each
to
read and write. (Compare this example with the
sample program for Function
27H,
that specifies a record
count
of
1
and
a
record length equal to file
size.)
current-record
f ile-size
equ
32
;offset
-
Current Rec field
equ
16
;offset
-
File
Size
field
fcb db
37
dup
(7)
f
i
lename db
17
dup(7)
prompt1 db "File
to
copy:
$"
;5ee
Function
E9H
for
prompt
2
db "Name of copy:
$"
;explanation of
$
crlf db
1
3,l
0
,"$"
num-recs dw
7
buffer db
32767
dup(7)
func-28H: set-dta buffer
;5ee
Function
1AH
display prompt
1
;see
Function E9H
get-string 15,filename
;5ee
Function ERH
display crlf
;see
Function E9H
parse filename[21,fcb
;see
Function 29H
open fcb
;see
Function
EFH
mov fcb[current-record1,E
;set Current Record
;field
set-relative-record fcb
;see
Function 24H
mov ax, word ptr fcb [file-size1
mov num-recs,ax ;5ave
it
for
ran-block-read fcb,num-rec5,l
;THIS
FUNCTION
display prompt2
;see
Function E9H
get-string 15,filename
;see
Function %RH
display
crlf
:see
Function 89H
parse filenameI21,fcb
;see
Function
29h
create fcb
;see
Function 16H
mov
fcb[current-
;5et
Current
set-relative-record fcb
;5ee
Function 24H
mov ax, file-length ;get
size
of
ran-block-write fcb,num-recs,l
;5ee
Function 28H
close fcb
:5ee
Function
18H
;get file
size
;ran-block-write
record1
,E
;Record field
;or
ig
ina
I
____
81