Chapter
1
I
System
Calls
Example:
The following program prompts for a letter, converts the letter
to
its alphabetic sequence (A
=
1,
B
=
2,
etc.), and then reads and
displays the corresponding record from
a
file named ALPHA-
BET.DAT on the disk in Drive B. The file contains
26
records;
each
record
is
28
bytes long.
record-size
relative-record
fcb db
db
buffer db
prompt db
crlf db
equ 14 ;offset of Recordsize
equ
33
;offset of RelativeRecord
;fieldof FCB
;fieldof FCB
2,
"ALPHABETDAT"
25
dup
(7)
34 dup(?),"$"
"Enter Letter:
$"
13,10,"$"
func-21H: set -d ta buffer
;see
Function
1AH
open fcb ;seeFunctionBFH
mov fcb[record_size1,28 ;set recordsize
get-char: display prompt ;seeFunction 09H
read-kbd-and-echo ;seeFunction
01H
CmP a1,BDH ;justaCR7
le
a1
1-done ;yes, gohome
sub
a1,41H ;convert
ASCII
code
mov fcb[relative-record1,al ;set relative
display crlf ;seeFunction 09H
read-ran
fcb ;THISFUNCTION
display buffer ;seeFunction 09H
display crlf ;seeFunction 09H
Imp get-char
;get another char
all-done: close fcb ;seeFunctionlBH
;to recorda
;record
70