1 STA SEGMENT STACK
2 DW 40H DUP(?)
3 TOP LABEL WORD
4 STA ENDS
5 ;---------------------------------------------
6
7 DATA SEGMENT
8 F1 DB 100 DUP(?)
9 F1H DW ?
10 BUFF DB 100 DUP(?)
11 ERRMSG DB 'ERROR',07,24H
12 DATA ENDS
13
14 ;----------------------------------------------
15 CODE SEGMENT
16 ASSUME DS:DATA,CS:CODE,SS:STA
17 MAIN PROC FAR
18 MOV AX,STA
19 MOV SS,AX
20 MOV SP,TOP
21 MOV AX,DATA
22 MOV DS,AX
23
24 ;-----------------------------------------------
25 MOV SI,0
26 L2:MOV AH,1
27 INT 21H
28 CMP AL,0DH
29 JE TOT
30 MOV F1[SI],AL
31 INC SI
32 JMP L2
33
34 ;--------------------------------------------
35 TOT: MOV AH,3DH
36 MOV AL,0
37 LEA DX,F1
38 INT 21H
39 JC ERROR
40 MOV F1H,AX
41 ;-----------------------------------------------
42
43
44
45 NEA:MOV AH,3FH
46 MOV BX,F1H
47 MOV CX,20
48 LEA DX,BUFF
49 INT 21H
50 JC ERROR
51 CMP AX,0 ;判断是否到了文件的结尾
52 JE EXIT
53 ;-------------------------------------------------
54 MOV CX,AX
55 MOV AH,40H
56 MOV BX,1
57 LEA DX,BUFF
58 INT 21H
59 JC ERROR
60 JMP NEA
61
62 ;-------------------------------------------------
63
64 ERROR:MOV AH,9
65 LEA DX,ERRMSG
66 INT 21H
67 JMP L0
68
69 EXIT:MOV AH,3EH
70 MOV BX,F1H
71 INT 21H
72 JC ERROR
73
74
75 L0:MOV AH,4CH
76 INT 21H
77
78 MAIN ENDP
79 CODE ENDS
80 END MAIN
81