, 1 3, ( - ) . , - - 0, IBM PC XT. AT 7 DMA - MOVS, - . - , . 46H 4AH - . 0BH 0CH. 8237 . 16- , , . , . 2 05H; - , . , - . 20- , , , 3000:ABCD 3ABCD. 16 , 2 04H. . 4 , 2 81H. , 4 . , DS 20- . . , DS 1F00H, - 2000H, 1F00 + 2000 = 21000H. , 2 0AH, 2. DMA , . 8237: 1. . 2. 20- , - , 2. 3. ( 1) - 2. 4. . , , . . : # 1 0 2 1 3 2 4 5 6 7 (0-3) 1-7 , : 0: 7-6 00 = 01 = , 10 = 11 = , .. 5 1 = 4 1 = 3 1 = 2 1-0 1: 7 1 = 6 ( 0) 5 1 = 4 1 = 3 ( 0) 2 1 = 1 1 = - 0 1 = 2: 7 ( 0) 6 1 = 5 1 = 4 1 = 3 1 = 2 1 = 1 1 = 0 1 = - , . , : 3: 7 1 = 6 1 = 5 1 = 4 1 = 3 1 = 2 1-0 , - " " (Sense Drive Sta- tus). 4, 1 0, 2. 3. , , DOS BIOS, BIOS, 0040:0042. 0040:0041, : 80H 40H 20H 10H ( CRC) 09H 64K 08H DMA 04H 02H 01H , 12, 1, 0 - A 512- . - . - IBM PC XT. - PCjr AT, - . AT , , JMP SHORT $+2 OUT, . , . ;--- BUFFER DB 512 DUP(?) STATUS_BUFFER DB 7 DUP(?) SECTOR_READ PROC ; ;--- STI ; MOV DX,3F2H ; MOV AL,28 ; 2, 3 4 OUT DX,AL ; ;--- ( 1/2 .) MOV CX,3500 ; ( IBM PC XT) MOTOR_DELAY: LOOP MOTOR_DELAY ; 1/2 ;--- MOV AH,15 ; CALL OUT_FDC ; MOV AH,0 ; CALL OUT_FDC ; MOV AH,12 ; CALL OUT_FDC ; CALL WAIT_INTERRUPT ; ;--- (25 .) MOV CX,1750 ; ( IBM PC XT) WAIT_SETTLE: LOOP WAIT_SETTLE ; 25 . ;--- DMA MOV AL,46H ; OUT 12,AL ; OUT 11,AL ; ;--- MOV AX,OFFSET BUFFER ; DS MOV BX,DS ; DS BX MOV CL,4 ; ROL BX,CL ; 4 MOV DL,BL ; DL BL AND DL,0FH ; DL AND BL,0F0H ; BX ADD AX,BX ; JNC NO_CARRY ; , # DL INC DL ; DL, NO_CARRY: OUT 4,AL ; MOV AL,AH ; OUT 4,AL ; MOV AL,DL ; OUT 81H,AL ; ;--- MOV AX,511 ; OUT 5,AL ; MOV AL,AH ; OUT 5,AL ; MOV AL,2 ; 2 OUT 10,AL ;DMA ;--- MOV AL,1EH ; , MOV AH,35H ; INT 21H ; ;--- MOV AH,66H ; CALL OUT_FDC ; MOV AH,0 ; CALL OUT_FDC ; MOV AH,12 ; CALL OUT_FDC ; MOV AH,0 ; CALL OUT_FDC ; MOV AH,1 ; CALL OUT_FDC ; MOV AH,ES:[BX]+3 ; CALL OUT_FDC ; MOV AH,ES:[BX]+4 ; CALL OUT_FDC ; MOV AH,ES:[BX]+5 ; CALL OUT_FDC ; MOV AH,ES:[BX]+6 ; CALL OUT_FDC ; CALL WAIT_INTERRUPT ; ;--- MOV CX,7 ; 7 LEA BX,STATUS_BUFFER ; NEXT: CALL IN_FDC ; MOV [BX],AL ; INC BX ; LOOP NEXT ; ;--- MOV DX,3F2H ; MOV AL,12 ; 3 4 OUT DX,AL ; RET ; SECTOR_READ ENDP WAIT_INTERRUPT PROC ; ;--- 6 BIOS MOV AX,40H ; BIOS MOV ES,AX ; ES MOV BX,3EH ; AGAIN: MOV DL,ES:[BX] ; TEST DL,80H ; 7 JZ AGAIN ; AND DL,01111111B ; 7 MOV ES:[BX],DL ; RET WAIT_INTERRUPT ENDP OUT_FDC PROC ; AH FDC MOV DX,3F4H ; KEEP_TRYING: IN AL,DX ; TEST AL,128 ; 7 ? JZ KEEP_TRYING ; , INC DX ; MOV AL,AH ; AH OUT DX,AL ; RET OUT_FDC ENDP IN_FDC PROC ; FDC AL MOV DX,3F4H ; ONCE_AGAIN: IN AL,DX ; TEST AL,128 ; 7 ? JZ KEEP_TRYING ; , INC DX ; IN AL,DX ; RET IN_FDC ENDP 5.4.2 / . - - , . , - . , - . DOS BIOS . -. IBM PC, XT PCjr BIOS (0 1), (0-39) (1-8). - 8 . AT 8, 9 15, 39 79. DOS - , . , . . 0 0 1 1 0, 0 1 .. ( .) , . 360K ( ) 18. , . 3 2 3*18 0-2 9 0 3 , 3 1. 64. 1 . . 5-4 DOS BIOS. . . . . 9 3 1 360K. , &H1000, , &H2000 (, , 16). - &H25 &H26. . 100 DEFINT A-Z ' 110 DATA &H55, &H8B, &HEC, &H1E, &H8B, &H76, &H0C, &H8B 120 DATA &H04, &H8B, &H76, &H0A, &H8B, &H14, &H8B, &H76 130 DATA &H08, &H8B, &H0C, &H8B, &H76, &H06, &H8A, &H1C 140 DATA &H8E, &HD8, &H8B, &HC3, &H8B, &H00, &H00, &HCD 150 DATA &H25, &H59, &H1F, &H5D, &HCA, &H08, &H00 160 DEF SEG = &H1000 ' &H10000 170 FOR N = 0 TO 38 ' 180 READ Q: POKE N,Q ' 190 NEXT ' 200 READSECTOR = 0 ' , 210 BUFFER = &H2000 ' &H20000 220 LOGICALNUMBER = 62 ' 62 230 NSECTORS = 9 ' 240 DRIVE = 0 ' (0 = A) 250 CALL READSECTOR (BUFFER, LOGICALSECTORS, NSECTORS, DRIVE) 260 ' , 2000:0000 . BIOS 2 13H 3 13H . DL 0 3, 0 = A, 1 = B .., DH - (), 0-1. CH 0 39, CL - 0 8. AL , . , . ES:BX , - . AL - . , . 1, AH , [5.4.8]. ;--- BUFFER DB 4000 DUP(?) ; ;--- MOV AX,SEG BUFFER ;ES:BX MOV ES,AX ; MOV BX,OFFSET BUFFER ; MOV DL,0 ; MOV DH,0 ; MOV CH,0 ; MOV CL,1 ; MOV AL,1 ; MOV AH,2 ; INT 13H ; DOS 25H 26H - , . - DX, DS:BX . CX , AL - , 0 = A, 1 = B .. , . , - . ( CX). ;--- BUFFER DB DUP 5000(?) ; ;--- PUSH DS ; MOV AX,SEG BUFFER ;DS:BX MOV DS,AX ; MOV BX,OFFSET BUFFER ; MOV DX,63 ; MOV CX,9 ; MOV AL,0 ; A INT 25H ; POP CX ; POP DS ; JNC NO_ERROR ; , CMP AH,3 ; . . NO_ERROR: ; 1, AH AL - . AH = 4, , AH = 2, . AH = 3, , . AH - . . - . , [5.4.1]. 5.4.3 . . "" , / . , , . , , - / , . . MS DOS, - . DOS , . , , DOS , . , - ASCII 26 (Ctrl-Z). . DOS - ; . ASCII 26. . , OPEN. . - : 100 OPEN "MYFILE" FOR OUTPUT AS #1 100 OPEN "O", #1, "MYFILE" "O" (output). #1 , , WRITE #1 INPUT #1. MYFILE . , OPEN . , , .. . , , , OPEN OPEN "MYFILE" FOR APPEND AS #1. . [5.3.3]. PRINT# WRI- TE#. : 100 PRINT #1, S$ 100 WRITE #1, X #1 ( - ), OPEN. , , . - , . , 232 2- , X = 232, PRINT #1, X , ASCII 2, 3 2. PRINT# WRITE# - . . - , WRITE# - . , 100 PRINT #1, A$, Z, B$ 100 WRITE #1, A$, Z, B$. /- (, ). ? PRINT#, . . WRITE#, - , . , , - , WRITE#. . , , PRINT# WRITE#. PRINT# - / , WRITE# - , - ( ). , , , WRITE# , - - . , , , - , , - . PRINT #1, A$, B$ B$ A$, PRINT #1, A$; B$ - ; . PRINT# PRINT #1 USING..., - PRINT USING . , PRINT#, . . , - PRINT# WRITE# , , . , - , . CLOSE, , CLOSE #1 - #1 CLOSE #1, #3 - #1 #3. , . WRITE# PRINT# - , , - . CLOSE. . : 100 OPEN "A:NEWSEQ" FOR OUTPUT AS #1 ' 110 A$ = "aaaaa" ' 120 B$ = "bbbbb" ' 130 C$ = "ccccc" ' 140 WRITE #1, A$, B$, C$ ' 150 CLOSE ' . MS DOS - , . FCB . , - , , . , , - , . , . , , "- " . , . FCB: 15H 21H - . , [5.3.5]. , 16H, "" , . 0FH, , , . , , - . , DS:DX FCB 15H . , , 14 FCB, 128 . , 512 , , - , ; . - . 15H, AL 0, , 1 - 2 - . 5 256 . . , WORKAREA. - DTA , DTA - , 256 . , [1.3.1], . ;--- WORKAREA DB 2000 DUP (?) ; FCB DB 1,'FILENAMEEXT',25 DUP (0) ;---DTA LEA DX,WORKAREA ;DS:DX DTA MOV DI,DX ; MOV AH,1AH ; DTA INT 21H ; DTA ;--- MOV AH,16H ; LEA DX,FCB ;DS:DX FCB INT 21H ; ;--- LEA BX,FCB ;BX FCB MOV AX,256 ; 256 MOV [BX]+14,AX ; ;--- MOV CX,5 ; NEXT_REC: MOV AH,15H ; LEA DX,FCB ; FCB INT 21H ; CMP AL,2 ; JE CONTINUE ; CMP AL,1 ; JE DISK_FULL ; ;--- , DTA ADD DI,256 ; 1 MOV DX,DI ;DS:DX DTA MOV AH,1AH ; DTA INT 21H ; LOOP NEXT_REC: ; ;---, LEA DX,FCB ;DS:DX FCB MOV AH,10H ; INT 21H ; - . , , . , , DTA, , . , . 0FH. : - . , . , , , 2000 , 1000 . ( 3DH), , , , , 2000 , . , 3CH 21H [5.3.2]. , , . , 3DH 21H [5.3.3]. . , 3CH, , . BX, CX. DS:DX 40H 21H. , , AX 5, - 6 - . , AX ; - , . , , . [5.1.2]. : ;--- PATH DB 'B:FILENAME.EXT',0 ; DATA_BUFFER DB 2000 DUP (?) ;--- "" LEA DX,PATH ;DS:DX MOV CX,0 ; ( ) MOV AH,3CH ; INT 21H ; JC OPEN_ERROR ; MOV HANDLE,AX ; ;--- 1000 MOV AH,40H ; MOV BX,HANDLE ; BX MOV CX,1000 ; , LEA DX,DATA_BUFFER ;DS:DX INT 21H ; JC OUTPUT_ERROR ; CMP CX,2000 ; JNE FULL_DISK ; 3DH 21H, 1 AL, 2, . , . - , . 42H 21H. 2 AL, , BX. CX:DX , , . - . , AX 1, AL , 6 - . : ;--- PATH DB 'B:FILENAME.EXT',0 ; DATA_BUFFER DB 1000 DUP(?) ;--- LEA DX,PATH ;DS:DX MOV AL,1 ; MOV AH,3DH ; INT 21H ; JC OPEN_ERROR ; MOV HANDLE,AX ; ;--- MOV BX,AX ; BX MOV CX,0 ;CX:DX MOV DX,0 ; MOV AL,2 ; MOV AH,42H ; INT 21H ; JC POINTER_ERROR ; ;--- 300 MOV AH,40H ; MOV BX,HANDLE ; BX MOV CX,300 ; LEA DX,DATA_BUFFER ;DS:DX INT 21H ; JC OUTPUT_ERROR ; CMP CX,300 ; JNE FULL_DISK ; 5.4.4 . - , , . . , . - - , . , . . , , , , , - . INPUT# , , / . LINE INPUT# CR/LF, , . . INPUT#, , [5.3.3] (, OPEN "A:NEWSEQ" FOR INPUT AS #1). 1, INPUT #1, X$, Y$, Z$ . , , INPUT #1, X, Y, Z , . , . : 100 DIM ITEM$(40) ' 40 110 FOR N = 0 TO 39 ' 120 INPUT #1, ITEM$(N) ' 130 NEXT ' n- . , , . LINE INPUT# INPUT#, , . 254 . / , , , LINE INPUT#. . EOF ( ) - , . -1, 0 - . - , ; , #2, X = EOF(2). : 100 OPEN "TEXT.AAA" FOR INPUT AS #2 ' 110 DIM TEXT$(500) ' 500 120 LINECOUNT = 0 ' 130 LINE INPUT #2, TEXT$(LINECOUNT) ' 140 IF EOF(2) THEN 170 ' 150 LINECOUNT = LINECOUNT + 1 ' 160 GOTO 130 ' 170 ... ' INPUT$ . - . 30 #1 : S$ = INPUT$(30,#1). , 254, , . INPUT$ - . , - 200 , , : 100 OPEN "A:NEWFILE" FOR INPUT AS #1 ' 110 CLS: DEF SEG = &HB000 ' 120 FOR N = 0 TO 9 ' 10 130 S$ = INPUT$(20,#1) ' 20 140 FOR M = 1 TO 20 ' 150 POKE N*160 + M*2, ASC(MID$(S$,M,1) ' 160 NEXT M ' 170 NEXT N ' . MS DOS - , - . - . , , . FCB: 14H 21H . , [5.3.5]. 0FH - 21H [5.3.3]. DS:DX FCB, 14H . 14 FCB. ,