, DOS , 128. , DTA. DTA , DTA , - . DTA , , , , . (DB, 1FH) (DW, 0CH) , - , (- FCB). 1, 128 . AL 0, . - AL 1, 14H 3 - . - . 256 . , , DTA , - . ;--- FCB FCB DB 0,'OLDDATA DAT', 25 DUP(0) DATA_AREA DB 512 DUP (?) ; DTA ;--- DTA LEA DX,DATA_AREA ;DS:DX DTA MOV DI,DX ; MOV AH,1AH ; DTA INT 21H ; DTA ;--- LEA DX,FCB ;DS:DX FCB MOV AH,0FH ; INT 21H ; CMP AL,0 ; JNE OPEN_ERROR ; ;--- 256 LEA BX,FCB ;DS:DX FCB MOV AX,256 ; MOV DS:[BX]+14,AX ; ;--- MOV CX,2 ; NEXT_REC: MOV AH,14H ; LEA DX,FCB ;DS:DX FCB INT 21H ; CMP AL,0 ; ? JE CONTINUE ; CMP AL,2 ; JE READ_ERROR ; . . CONTINUE: ADD DI,256 ; MOV DX,DI ;DX DTA MOV AH,1AH ; DTA INT 21H ; DTA LOOP NEXT_REC ; ;---, LEA DX,FCB ;DS:DX FCB MOV AH,10H ; INT 21H ; CMP AL,0FFH ; JE CLOSE_ERROR ; : 3FH 21H - . , . 3DH 21H 0 AL, , 2 - . . - , - , . , - - . , , , 512 , , - . - , . , , , . , - , . , . . AL 2 42H, , . CX DX 0, , . DX:AX , - , .., , . , ; , - , AL 0. 42H , , AX 1, , 6 - - . . BX, CX . AX . AX , . , AX 5 - - 6 - . . - , . , , - [1.3.1]. ;--- PATH DB 'A:FILENAME.EXT'0 ; DATA_BUFFER DB 1000 DUP (?) ; HANDLE DW ? ; FILESIZE DW ? ; ;--- LEA DX,PATH ;DS:DX MOV AL,0 ; MOV AH,3DH ; INT 21H ; JC OPEN_ERROR ; MOV HANDLE,AX ; ;--- MOV AH,42H ; MOV AL,2 ; MOV BX,HANDLE ; MOV CX,0 ; MOV DX,0 ; INT 21H ; JC POINTER_ERROR1 ; MOV FILESIZE,AX ; ( 64K) ;--- MOV AH,42H ; MOV AL,0 ; MOV CX,0 ; MOV DX,0 ; INT 21H ; JC POINTER_ERROR2 ; ;--- MOV AH,3FH ; MOV BX,HANDLE ; MOV CX,FILESIZE ; LEA DX,DATA_BUFFER ;DS:DX INT 21H ; JC READ_ERROR ; ;---, MOV BX,HANDLE ; MOV AH,3EH ; INT 21H ; JC CLOSE_ERROR ; 5.4.5 . - , . , , - ( n- , ). . , - , . . [5.3.3] . , - , . OPEN , . , OPEN "R", 1, "NEW- DATA", 20 NEWDATA 20 ( #1). , FIELD. FIELD . , 20 FIELD 1, 14 AS LASTNAME$, 2 AS DEPOSIT$, 4 AS ACCTNUM$. 1 , FIELD , #1. , FIELD. RSET LSET , (RSET) (LSET) . , , "SMITH" 14- LASTNA- ME$, RSET LASTNAME$ = "SMITH", N$ "SMITH", RSET LASTNAME$ = N$. - RSET LSET. , 14 . RSET , - LSET, . , FIELD . - - - . - , - , . , ; . , - - . . MKI$, MKS$ MKD$, - , , . - RSET LSET, , RSET = ACCTNUM$ = MKI$(X), X - , ACCTNUM$ - FIELD. RSET LSET, PUT#. PUT #1, 245 - 245, #1. , , - ( 1). - , . , PUT, , , , , - . LOC - . #3, X = LOC(3). LOF ( ) . , , . 1 , , . #2, 32 , RECORDNUM = LOF(2)/32 + 1. 24 , . - , , . 120 . , - PUT. - , . 100 OPEN "R", 1, "A:NEWDATA.DAT", 24 ' 110 FIELD 1, 18 AS LASTNAME$, 2 AS AGE$, 4 AS WEIGHT 120 R = LOF(1)/24 + 1 ' + 1 130 CLS ' 140 INPUT "Enter name:",N$ ' () 150 INPUT "Enter age:",A% ' () 160 INPUT "Enter weight:",W! ' () 170 RSET LASTNAME$ = N$ ' 180 RSET AGE$ = MKI$(A%) ' 190 RSET WEIGHT$ = MKS$(W!) ' 200 PUT #1, R ' 210 R = R + 1 ' 220 PRINT: PRINT "Do another (y/n)?" ' 230 C$ = INKEY$: IF C$ = "" THEN 220 ' 240 IF C$ = "y" THEN CLS: GOTO 130 ' , 250 CLOSE ' . MS DOS - , - , . , , . : 0FH DS:DX . FCB. 22H 21H, DTA , FCB. - , . - , 22H . 22H AL 00, . 1, 2 - , (.. , - , , FCB). ;--- FCB DB 1, 'NEWDATA ', 25 DUP (0) DTA DB 256 DUP (?) ;--- FCB MOV AH,0FH ; LEA DX,FCB ;DS:DX FCB MOV BX,DX ; FCB INT 21H ; MOV AX,256 ; MOV [BX]+14,AX ; MOV AX,233 ; MOV [BX]+33,AX ; MOV AX,0 ; MOV [BX]+35,AX ; ;--- DTA MOV AH,22H ; LEA DX,FCB ;DS:DX FCB INT 21H ; CMP AL,0 ; JNE WRITE_ERROR ; ;---, LEA DX,FCB ;DS:DX FCB MOV AH,10H ; INT 21H ; CMP AL,0FFH ; JE CLOSE_ERROR ; - , . MS DOS FCB, . - 28H 21H. DS:DX - FCB, . . ( ) , CX ( "" 128 , - - , ). CX . AL 0, , 1 - - , . 22H - , - FCB, , . , CX = 0, , - , - . : - . , - , . 42H - 21H. BX, CX:DX (CX ). AL 0 2. AL = 0, CX:DX ; AL = 1, CX:DX - , AL = 2, - CX:DX (.. ). - . DX:AX - ( DX). , . AX 1, AL 6 - . 40H 21H, . BX , CX - , . AX - . CX, (. [5.1.4]). , . AX 5 6 - . - , DTA . . , - , - . ;--- HANDLE DW ? ; FILEPATH DB 'A:NEWDATA',0 ; REC_BUFFER DB 30 DUP (?) ; ;--- MOV AH,3DH ; MOV AL,1 ; LEA DX,FILEPATH ;DS:DX INT 21H ; JC OPEN_ERROR ; MOV HANDLE,AX ; ;--- MOV AX,30 ; 30 MOV CX,54 ; #54 (55- ) MUL CX ; DX:AX MOV CX,DX ; DX MOV DX,AX ; CX MOV AL,0 ; MOV AH,42H ; MOV BX,HANDLE ; INT 21H ; JC POINTER_ERROR ; ;--- MOV AH,40H ; MOV BX,HANDLE ; MOV CX,30 ; LEA DX,REC_BUFFER ;DS:DX INT 21H ; JC WRITE_ERROR ; FCB - - . , , . 5.4.6 . . MS DOS , . , - . - , . - [5.4.5] - , - . . , , . GET# . GET #1,23 #23 , #1. , FIELD, . , FIELD FIELD 1, 20 AS X$, 2 AS Y$, GET 1,23 X$ - 20- 23, Y$ - 10- . , RSET LSET . , , MKI$, MKS$ MKD$. , , - CVI, CVS CVD. Y$ , Y% = CVI(Y$), Y% , - . , , 0 65535, ASCII. , [5.4.5], : 100 OPEN "A:NEWDATA" AS #1 LEN = 24 ' 110 FIELD 1, 18 AS LASTNAME$, 2 AS AGE$, 4 AS WEIGHT$ 120 CLS: INPUT "What is the record number";R ' 130 IF R*24 > LOF(1) THEN BEEP: PRINT"No such record": GOTO 120 140 GET #1,R ' 150 PRINT LASTNAME$, CVI(AGE$), CVS(WEIGHT$) ' 160 PRINT: PRINT "Do another (y/n)?" ' ? 170 C$ = INKEY$: IF C$ = "" THEN 170 ' 180 IF C$ = "y" OR C$ = "Y" THEN 120 ', 190 CLOSE ' . FCB - . , , - . . FCB: 21H 21H . , 27H, - . , [5.3.5] [5.3.3]. FCB , (DW 14) (DD 33). DS:DX FCB, 21H , DTA. , AL 0. , , - , , . , , AL 1 3. 3, . 1, - . DTA: ;--- FCB DB 1,'OLDDATA ', 25 DUP (0) ;--- FCB MOV AH,0FH ; LEA DX,FCB ;DS:DX FCB MOV BX,DX ; FCB INT 21H ; MOV AX,55 ; 55 MOV [BX]+14,AX ; MOV AX,22 ; MOV [BX]+33,AX ; MOV AX,0 ; MOV [BX]+35,AX ; ;--- DTA MOV AH,21H ; LEA DX,FCB ;DS:DX FCB INT 21H ; , DTA CMP AL,0 ; JNE READ_ERROR ; ;---, MOV AH,10 ; LEA DX,FCB ;DS:DX FCB INT 21H ; 27H 21H. , 21H, - , CX - . CX . AL , 21H. 21H FCB, - ( , ) , . , , , FCB . , - , 24H 21H, . , , DS:DX FCB. , . : , - . , , . DS:DX , , 3FH 21H. CX , BX - . ;--- HANDLE DB ? FILEPATH DB 'A:OLDDATA',0 REC_BUFFER DB 30 DUP(?) ;--- MOV AH,3DH ; MOV AL,0 ; LEA DX,FILEPATH ;DS:DX INT 21H ; JC OPEN_ERROR ; MOV HANDLE,AX ; ;--- MOV AX,30 ; MOV CX,54 ; #54 (55- ) MUL CX ; DX:AX MOV CX,DX ; DX MOV DX,AX ; CX MOV AL,0 ; MOV AH,42H ; MOV BX,HANDLE ; INT 21H ; JC POINTER_ERROR ; ;--- MOV AH,3FH ; MOV BX,HANDLE ; MOV CX,30 ; LEA DX,REC_BUFFER ;DS:DX INT 21H ; JC READ_ERROR ; ;---, MOV BX,HANDLE ; MOV AH,3EH ; INT 21H ; JC CLOSE_ERROR ; 5.4.7 /. MS DOS . , , . , , - . VERIFY = ON CONFIG.SYS, . , . - . DOS . - , , [7.2.5]. . 2EH 21H . AL 1 - 0 - - . DL 0. - . . ;--- MOV AL,1 ; MOV DL,0 ; MOV AH,2EH ; INT 21H ; - 54H 21H. . AL = 1, AL = 0, . 5.4.8 . , - . , . , - - . , (soft) (hard). - : , . , - , . , . . [7.2.5] - . ON ERROR GOSUB . , : 52 Bad file number. ( .) - , (#1, #2 ..) 53 File not found. ( .) LOAD, KILL, NAME, FILES OPEN. 54 Bad file mode. ( .) - , , , , - , . 55 File already open. ( .) , , (KILL) , . 58 File already exists. ( .) ( NAME) , . 61 Disk full. ( .) . [5.1.4], . 62 Input past end. ( .) - , . - EOF, [5.4.4]. 63 Bad record number. ( .) , . 64 Bad file name. ( .) KILL, NAME FILES. 67 Too many files. ( .) . - , , . 70 Disk is write-protected. ( .) 71 Disk is not ready. ( .) , . 72 Disk media error. ( .) , , . 74 Specified wrong disk in RENAME operation. ( RENAME.) 75 Path/file access error. ( .) , . , . . OPEN, NAME, MKDIR, CHDIR RMDIR. 76 Path not found. ( .) . OPEN, MKDIR, CHDIR RMDIR. , - . , , RESUME , . RESUME , , , (, ). - , : 100 ON ERROR GOSUB 5000 ' . . 600 ''' . . 5000 ''' 5010 IF ERR = 61 PRINT "Disk full": GOTO 5100 5020 IF ERR = 70 PRINT "Disk is write protected": GOTO 5100 . . 5100 PRINT "Correct the problem, then strike any key" 5110 C$ = INKEY$: IF C$ = "" THEN 5110 5120 RESUME 600 . 1 13H AL , . : 0-1 01 = , , 3 = 1, 64K 10 = 11 = 2 1 = 3 1 = DMA ( ), , 0 = 1, - 64K 4 1 = , 5 1 = 6 1 = 7 1 = (-) MS DOS , - . . , AX. , - : 1 2 3 4 5 ( ) 6 15 16 17 18 ( - ) "" . . - . - , . [7.2.5] . MS DOS 3.0 . 59H 21H, - . . [7.2.5].  6. .  1. . MS DOS (LPT1 - LPT3) . - , , , ; 1 7. . - / . BIOS . . LPT1 - 0040:0008, LPT2 - 0040:000A .. LPT - , . , , , - . , - 0, . (PC/XT/AT) 3BCH 3BDH 3BEH PC/XT PCJr 378H 379H 37AH / AT ( LPT1) / 278H 279H 27AH AT ( LPT2) - , , . - ; , , . , . -