B:, : COMMAND_LINE DB 12,'B: /C DIR A:',13 , [1.3.2]: LEA BX,PARAMETERS ; - MOV AX,OFFSET COMMAND_LINE ; . MOV [BX]+2,AX ; 1- 2 MOV AX,SEG COMMAND_LINE ; . MOV [BX]+4,AX ; 2- 2 1.3.4 . , , . - . MS DOS - , , - . COM, - [1.3.6]. , EXE - . 27H . CS PSP , . COM, CS - , 27H. EXE , CS , PSP (.. 100H). - EXE RET - : PUSH DX / MOV AX,0 / PUSH AX. DS PSP, - 0 PSP, INT 20H. INT 20H , - DOS. . 1-5 . 27H EXE 27H PSP ( INT), RET. - 27H, DX - , PSP. . 25H - 21H, [1.2.3] ( 70H). , IRET. , - , , DX - . COM INT 27H . EXE PSP RET. , - INT 70H. (COM EXE). FINISH (, $ ). COM FINISH PSP, 27H. EXE - , PSP, - 100H, PSP. , , . MOVSB PSP, 60H, 160 . COM: ;--- BEGIN: JMP SHORT SET_UP ; ROUTINE PROC FAR PUSH DS ; . () . POP DS ; IRET ; FINISH EQU $ ; ROUTINE ENDP ;--- SET_UP: MOV DX,OFFSET ROUTINE ; DX MOV AL,70H ; MOV AH,25H ; INT 21H ; ;--- , LEA DX,FINISH ; . INT 27H ; EXE: ;--- JMP SHORT SET_UP ; ROUTINE PROC FAR PUSH DS ; . () . POP DS ; IRET ; FINISH EQU $ ; ROUTINE ENDP ;--- SET_UP: MOV DX,OFFSET ROUTINE ; DX MOV AX,SEG ROUTINE ; DS MOV DS,AX ; MOV AL,70H ; MOV AH,25H ; INT 21H ; ;--- MOV DX,FINISH+100H ; MOV BYTE PTR ES:1,27H ; 27H PSP RET ; 31H 21H , , DX 16- , ( , PSP - . [1.3.1]). , , . 4DH 21H. [7.2.5]. 1.3.5 . - , , . , - , . , - . , - , - . . , - , , - . . MS DOS EXEC . , 4BH 21H, - , 0 AL [1.3.2]. AL 3, . PSP, - . , . . , . EXEC , , . , , , . , MS DOS - . . DOS , 4AH. - 48H , . - AX, , . [1.3.1]. 3, AL, . DS:DX , - , ASCII 0. , .COM .EXE, DOS , . , ES:BX 4- , (1) 2- , - (2) 2- , ( - [1.3.6]). , AX, . , . - , . , . , , . - , - AX. 1, , 2 - , 5 - 8 - - . , - (far) . , . . 16 ( ). - OVERLAY_OFFSET CODE_SEG . - , CALL DWORD PTR OVERLAY_OFFSET. , . DS. ;--- (. [1.3.1]): ZSEG SEGMENT ZSEG ENDS ;--- OVERLAY_SEG DW ? OVERLAY_OFFSET DW ? ; CODE_SEG DW ? ; - PATH DB 'A:OVERLAY.EXE' ; 0BLOCK DD 0 ;4- ;--- MOV CODE_SEG,CS ; CS MOV AX,ES ; PSP MOV BX,ZSEG ; SUB BX,AX ; MOV AH,4AH ; SETBLOCK INT 21H ; JC SETBLK_ERR ; ;--- MOV BX,100H ; 1000H MOV AH,48H ; INT 21H ; AX:0 JC ALLOCATION_ERR ; MOV OVERLAY_SEG,AX ; ;--- MOV AX,CODE_SEG ; MOV BX,OVERLAY_SEG ; SUB BX,AX ;BX MOV CL,4 ; 4 SHL BX,CL ; MOV OVERLAY_OFFSET,BX ; ;--- MOV AX,SEG BLOCK ;ES:BX MOV ES,AX ; MOV BX,OFFSET BLOCK ; MOV AX,OVERLAY_SEG ; MOV [BX],AX ; MOV [BX]+2,AX ; - LEA DX,PATH ;DS:DX MOV AH,48H ; EXEC MOV AL,3 ; INT 21H ; JC LOAD_ERROR ; ;--- . . CALL DWORD PTR OVERLAY_OFFSET ; . ; DWORD PTR, - . ; ;--- , DSEG SEGMENT ; , . ; ( . ; ) DSEG ENDS CSEG SEGMENT PARA PUBLIC 'CODE' OVERLAY PROC FAR ; "" ASSUME CS:CSEG,DS:DSEG PUSH DS ; DS MOV AX,DSEG; DS MOV DS,AX . . POP DS ; DS RET OVERLAY ENDP CSEG ENDS END 1.3.6 .EXE .COM. EXE COM. EXE , ; DOS - . , COM , - , . EXE 768 , COM ( ). COM , . , - , COM. - , - . , : MOV DX,OFFSET DATA_AREA MOV AX,SEG DATA_AREA MOV DS,AX DX DS. DS? - , , DATA_AREA , - MS DOS, , . - - . , DOS - , - , , . . 1-6 . COM , , . , - . 65535 , , ( , 65535 , 64K ). COM - PSP; EXE, DS ES - , CS PSP. COM - : 1. . , , START, - END START. 2. ORG 100H. - (.. ). COM 100H, , PSP, CS PSP, 100H . 100H JMP. 3. ASSUME DS, ES SS , , , ASSUME CS:CSEG, DS:CSEG, ES:CSEG, SS:CSEG. 4. , , . - , , , . - JMP. 5. MOV AX,SEG NEW_DATA. . , , , MOV AX,DSEG / MOV DS,AX. 6. . - 64K, (, ). COM 64K, SS SP . , - , , . . 7. RET, 20H. 20H - DOS. - RET, 20H. , - 0. RET, 0 , PSP. 20H, - , DOS. , DS 0 (PUSH DS / MOV AX,0 / PUSH AX), EXE . , - . COM c EXE2BIN, MS DOS. , MYPROG.EXE, - EXE2BIN MYPROG. MYPROG.BIN. - - MYPROG.COM. EXE2BIN MYPROG MYPROG.COM, - COM. . , . , COM . CSEG SEGMENT ORG 100H ASSUME CS:CSEG, DS:CSEG, SS:CSEG ;--- START: JMP SHORT BEGIN ; MESSAGE1 DB 'The dip switches are set for $' MESSAGE2 DB 'disk drive(s).$' ;--- BEGIN: MOV AH,9 ; 9 21H - MOV DX,OFFSET MESSAGE1 ; INT 21H ; PUSH AX ; ;--- A 8255 IN AL,61H ; B OR AL,10000000B ; 7 OUT 61H,AL ; IN AL,60H ; . AND AL,11000000B ; 2 MOV CL,6 ; AL SHR AL,CL ; 2 ADD AL,49 ; 1, 1 ; 48 ASCII MOV DL,AL ; DL MOV AL,61H ; B AND AL,01111111B ; 7 OUT 61H,AL ; ;--- MOV AH,2 ; 2 21H INT 21H ; DL ;--- POP AX ; MOV DX,OFFSET MESSAGE2 INT 21H ; INT 20H ; CSEG ENDS END START  2. .  1. . IBM PC 8253 ( 8254) . - , - , . 8253 , - . 8253 . . 8253 - , . , - 1/12 . - . , BIOS. - . 2-1. - . 18.2 0 ( ), . 0 12:00; 24 , . 18.2 . - , . 2.1.1 8253/8254. 8253 (8254 AT) . - ; 40H 42H 0 - 2. 8- /, - . , , . 16- (latch register), 16- - . , . , - , . , . - : . - , . . , . - IBM PC: 0 . - BIOS , 18.2 . 4- - 0040:006C ( - ). (- 8) . , , , , (. [1.2.2]). , , - . 1 PCjr, . [5.4.2] - DMA . PCjr 1 . PCjr - , , - . 1 - , . 2 . , . - , . 2 - . , 2 - . - 8255. , , (gate), . 0 1. 2, - . - 61H, - 8255; . [1.1.1]. - 2 - 1 61H - . . 2-2 8253. , . 1.19318 ( AT, , 1.19 ). , 16 , 65535 , 18.2, - 1/12 - . BIOS. - , . - , [2.1.7], - . 8253 6 . , 0 , 2 . , , . - .. , - . , , . 8- . 43H. - , - , , - . BCD ( ) . : 0 0, , BCD 3-1 , 1 - 5 (000 - 101) 5-4 : 00 = 01 = / 10 = / 11 = / , 7-6 , 0 - 2 (00 -10) , 8253 - . , . 1. (43H) , , , /, . 2. 2 , 1 0 61H. ( 1 1, 2 . 0 - .) 3. 0 65535, AX, , / (40H - 42H). 8253 . - 8253 . , - , , MS DOS . Ctrl-Break [3.2.8]. . 0 , BIOS . , , 18.2 . - , , 1000 , . 1193 (1193180 / 10000). . [2.1.8]. , 0 . - 65535 - 0 (0 65535 . ;--- / COMMAND_REG EQU 43H ; CHANNEL_0 EQU 40H ; 0 MOV AL,00110110B ; 2 OUT COMMAND_REG,AL ; ;--- MOV AX,1193 ; 100 /. OUT CHANNEL_2,AL ; MOV AL,AH ; OUT CHANNEL_2,AL ; 2.1.2 / . MS DOS . 4 , ( 0040:006C, ). , , .. - , . 18.2 . , --. , - , . - . . TIME$ ::, 0 23, . 5:10 : 100 TIME$ = "17:10:00" ' 110 PRINT TIME$ ' TIME$ , MID$, LEFT$ RIGHT$. , 17:10:00 5:10 , , ( VAL), 12, : 100 T$ = TIME$ ' 110 HOUR$ = LEFT$(T$,2) ' 120 MINUTES$ = MID$(T$,4,2) ' 130 NEWHOUR = VAL(HOUR$) ' 140 IF NEWHOUR > 12 THEN NEWHOUR = NEWHOUR - 12 150 NEWHOUR$ = STR$(NEWHOUR) ' 160 NEWTIME$ = NEWHOUR$ + ":" + MINUTES$ ' . MS DOS - , --. - 1/100 , - , - . 2CH 21H , 2DH - . CH ( 0 23, 0 ), CL - ( 0 59), DH - ( 0 59) DL - ( 0 99). 2CH, AL (0 = ). . DOS . , 2DH, AL (0 = - , FF = ). ;--- MOV CH,HOURS ; MOV CL,MINUTES ; MOV DH,SECONDS ; MOV DL,HUNDREDTHS ; MOV AH,2DH ; INT 21H ; CMP AH,0FFH ; JE ERROR ; ;--- MOV AH,2CH ; INT 21H ; MOV DAY_OF_WEEK,AH ; AH . 1 8253 , - . BIOS - 0 1.573 . , , 24 . , 0040:0070 , 1 ( ) . 2.1.3 / . MS DOS . BIOS. COMMAND.COM. , - , , 0, 0 1980 . , DOS COMMAND.COM. MS DOS, - . , -, - ( AUTOEXEC.BAT). -, . [2.1.4]. - , BIOS 24 , MS DOS . . DATE$ --. (/) (-). . 31- 1984 .: 100 DATE$ = "10/31/84" ' 110 PRINT DATE$ ' ... : 10-31-1984. . 2AH 2BH 21H . AH 2AH - . CX 0 119, 1980 - 2099 ( 1980 .). DH , DL - . MOV AH,2AH ; INT 21H ; MOV DAY,DL ; DL MOV MONTH,DH ; DH ADD CX,1980 ; MOV YEAR,CX ; , - 2BH. , , AL FF, - 0. MOV DL,DAY ; DL MOV DH,MONTH ; DH MOV CX,YEAR ; CX SUB CX,1980 ; 1980 MOV AH,2BH ; INT 21H ; CMP AH,0FFH ; JE ERROR ; , 2.1.4 / . , - - . , . , . - , - BIOS DOS , . - . . IBM PC , , , - . AT , MC146818 Motorola, , - , . , - 70H, 71H. , , : 00H 01H 02H 03H 04H 05H 06H 07H