Assembler






DOS
, , DOS,
. INT 27H.
 
DOS INT 20H,
0 ,
.EXE.
DOS. ,
. ,
INT 20H, DOS
, .
 
DOS INT 27H
. DOS ,
INT 20H, , ,
. DX

, . DOS
, . ,
DOS.
DOS .
 
PC DOS INT
27H, CS
. , INT 21H
.COM . .EXE,
CS DX ,
. .COM
.5, ,
.COM.
 
DOS INT 27H
. INT 27H,
BIOS .

.
 
. 10.1.
.
INT 17H -
BIOS.
. ,
. ,
.
,
, .

, .
 
A
Microsoft (R) Macro Assembler Version 5.00 4/2/89 16:06:27
. 10.1 Page 1-1
 
 
PAGE ,132
TITLE . 10.1
0000 ABS0 SEGMENT AT 0
0020 ORG 4*8H
0020 ???????? TIMER_INT DD ? ;
005C ORG 4*17H
005C ???????? PRINTER_INT DD ? ; BIOS
0408 ORG 408H
0408 ???? PRINTER_BASE DW ? ;
040A ABS0 ENDS
 
0000 CODE SEGMENT
0100 ORG 100H
ASSUME CS:CODE,DS:CODE,ES:CODE
0100 EB 09 90 JMP START
 
0103 ???????? PRINT_VECTOR DD ? ; 17h
0107 ???????? TIMER_VECTOR DD ? ; 9h
 
010B START:
010B 2B C0 SUB AX,AX ; ES ABS0
010D 8E C0 MOV ES,AX
ASSUME ES:ABS0
010F 26: A1 005C R MOV AX,WORD PTR PRINTER_INT
0113 26: 8B 1E 005E R MOV BX,WORD PTR PRINTER_INT+2
0118 26: 8B 0E 0020 R MOV CX,WORD PTR TIMER_INT
011D 26: 8B 16 0022 R MOV DX,WORD PTR TIMER_INT+2
0122 A3 0103 R MOV WORD PTR PRINT_VECTOR,AX
0125 89 1E 0105 R MOV WORD PTR PRINT_VECTOR+2,BX
0129 89 0E 0107 R MOV WORD PTR TIMER_VECTOR,CX
012D 89 16 0109 R MOV WORD PTR TIMER_VECTOR+2,DX
 
;-----
 
0131 FA CLI
 
. 10.1 ()
0132 26: C7 06 005C R 0162 MOV WORD PTR PRINTER_INT,offset PRINT_HANDLER
R
0139 26: 8C 0E 005E R MOV WORD PTR PRINTER_INT+2,CS
013E 26: C7 06 0020 R 0196 MOV WORD PTR TIMER_INT,offset TIMER_HANDLER
R
0145 26: 8C 0E 0022 R MOV WORD PTR TIMER_INT+2,CS
014A B0 36 MOV AL,00110110b
014C E6 43 OUT 43H,AL
014E B0 00 MOV AL,0 ; 256
0150 E6 40 OUT 40H,AL
0152 B0 01 MOV AL,1
0154 E6 40 OUT 40H,AL
0156 FB STI
0157 8D 16 28FE R LEA DX,BUFFER_END ;
015B CD 27 INT 27H ;
 
015D 00 TIMER_COUNT DB 0
015E 01EE R BUFFER_HEAD DW BUFFER_START
0160 01EE R BUFFER_TAIL DW BUFFER_START
 
;----- 17h
 
0162 PRINT_HANDLER PROC FAR
ASSUME CS:CODE,DS:nothing,ES:nothing
0162 0A E4 OR AH,AH
0164 74 05 JZ BUFFER_CHARACTER ;
0166 2E: FF 2E 0103 R JMP PRINT_VECTOR ;
; 17h
016B BUFFER_CHARACTER:
016B FB STI
016C 53 PUSH BX
016D 51 PUSH CX
016E 56 PUSH SI
016F 2B C9 SUB CX,CX ;
0171 PRINT_LOOP:
0171 2E: 8B 1E 0160 R MOV BX,BUFFER_TAIL ;
0176 8B F3 MOV SI,BX
0178 E8 01E2 R CALL ADVANCE_POINTER ;
017B 2E: 3B 1E 015E R CMP BX,BUFFER_HEAD ;
0180 74 0E JE BUFFER_FULL ; ,
0182 2E: 88 04 MOV CS:[SI],AL ;
0185 2E: 89 1E 0160 R MOV BUFFER_TAIL,BX ;
018A B4 00 MOV AH,0 ; 17h
018C PRINT_RETURN:
018C 5E POP SI
018D 59 POP CX
018E 5B POP BX
018F CF IRET
0190 BUFFER_FULL:
0190 E2 DF LOOP PRINT_LOOP ;
0192 B4 01 MOV AH,1 ; ,
0194 EB F6 JMP PRINT_RETURN
0196 PRINT_HANDLER ENDP
 
. 10.1 ()
;----- 4660
 
0196 TIMER_HANDLER PROC FAR
ASSUME CS:CODE,DS:nothing,ES:nothing
0196 50 PUSH AX
0197 53 PUSH BX
0198 2E: 8B 1E 015E R MOV BX,BUFFER_HEAD
019D 2E: 3B 1E 0160 R CMP BX,BUFFER_TAIL ; - ?
01A2 75 14 JNZ TEST_READY ; ,
 
;-----
 
01A4 TIMER_RETURN:
01A4 5B POP BX
01A5 2E: FE 06 015D R INC TIMER_COUNT ;
01AA 75 06 JNZ SKIP_NORMAL
01AC 58 POP AX ; 256
01AD 2E: FF 2E 0107 R JMP TIMER_VECTOR ;
;
01B2 SKIP_NORMAL:
01B2 B0 20 MOV AL,20H
01B4 E6 20 OUT 20H,AL ;
01B6 58 POP AX
01B7 CF IRET
 
;----- ,
 
01B8 TEST_READY:
01B8 52 PUSH DX
01B9 1E PUSH DS
01BA 2B D2 SUB DX,DX
01BC 8E DA MOV DS,DX ; DS ABS0
ASSUME DS:ABS0
01BE 8B 16 0408 R MOV DX,PRINTER_BASE
01C2 42 INC DX ;
01C3 EC IN AL,DX
01C4 A8 80 TEST AL,80H ;
01C6 74 16 JZ NO_PRINT
01C8 4A DEC DX ;
01C9 2E: 8A 07 MOV AL,CS:[BX] ;
01CC E8 01E2 R CALL ADVANCE_POINTER
01CF 2E: 89 1E 015E R MOV BUFFER_HEAD,BX
01D4 EE OUT DX,AL ;
01D5 83 C2 02 ADD DX,2 ;
01D8 B0 0D MOV AL,0DH
01DA EE OUT DX,AL ;
01DB B0 0C MOV AL,0CH
01DD EE OUT DX,AL
01DE NO_PRINT:
01DE 1F POP DS
01DF 5A POP DX
01E0 EB C2 JMP TIMER_RETURN ;
01E2 TIMER_HANDLER ENDP ;
 
01E2 ADVANCE_POINTER PROC NEAR
01E2 43 INC BX ;
 
. 10.1 ()
01E3 81 FB 28FE R CMP BX,offset BUFFER_END
01E7 75 04 JNE ADVANCE_RETURN ;
01E9 8D 1E 01EE R LEA BX,BUFFER_START ;
01ED ADVANCE_RETURN:
01ED C3 RET
01EE ADVANCE_POINTER ENDP
 
01EE BUFFER_START LABEL BYTE
01EE 2710[ DB 10000 DUP (?)
??
]
 
28FE BUFFER_END LABEL BYTE
28FE CODE ENDS
 
END
. 10.1 ()
 
.
, .
,
. DOS ,
. , 96K
, 10 ,
. 96
, 86 .
, , ,
.
 
.
PRINT (INT 17H) ,
, .
.
, ,
.
 

INT 17H -.
,
,
,
. , ,
,
Ctrl-PrtSc, .
 

, ,
.
. (
), DOS.
, Ctrl-PrtSc.
, DOS
, ,
.
.
.
.
.
,
"",
. ,
.
,
, ,
.
 
, . 10.1,
, . -,
ABS0, ,
.
INT 17H,
INT 8. , ABS0
PRINTER_BASE.
0. ,
.
 
CODE - ,
. ORG 100H
.COM. ,
.COM,
.5 .

PRINT_VECTOR TIMER_VECTOR.
,
.
 
CODE, START,
.

CODE.
,
. CLI,
.
,
.
,
,

. ,
.
 
,
.
18 .
80 .
,
18 .
, .
80
.
256, 256 .

TIMER_HANDLER.
 
DOS
INT 27H. DX
,
. ,
.
INT 27H DOS
.
 
.
,
.
START INT 27H
BUFFER_END. INT 27H

, DOS
. 90 10000
,
.
 
PRINT_HANDLER.
-
INT 17H
.
BIOS. ,
(AH = 0).
BIOS,
, AH . ,

.
BIOS, .
,
.
 

. -,
AH = 0 - . -
(AH = 2)
, BIOS
RESET. ,
,
.
,
.
 
, -
.
BIOS, ,
.
,
.
BIOS. IBM
BIOS , , - ,
. ,
,
,
.
, .


BIOS .
 
PRINT_HANDLER
. , ,
. , ,
. ,
BIOS ,
. CX
"".
64K, - , -
. PRINT_HANDLER , BIOS,
.
 

ADVANCE_POINTER.
.
, .
BIOS .
10000 , 16.
 
TIMER_HANDLER
.
,
.
, ,
, ,
.
 
,
.
, .
, TIMER_RETURN.
.
 
TIMER_RETURN ,
.
TIMER_COUNT .
,
.
,

TIMER_VECTOR.
BIOS .
.
BIOS 256
.
256 ,
- - 18,2
. ,
, .
256 , 5
,
.
 
256 ,
. ,
5 ,
10
, , .
, ,
, .
,
.
, 256 .
 
,
, ?
, , .

BIOS,
, .
,
TIMER_RETURN,
. ,
, . ,
,
.
. ,
.
 
,
.
, . , BIOS,
.
.
? ,
,
?
.

.
PRINT_HANDLER ,
INT
17H. , , , , .
 
,
. ,
. BASICA -
,
, .
BASICA ,
TIMER_HANDLER ,
. TIMER_HANDLER
BIOS,
256 . BASICA
, , , .
,
.
INT 27H .

BIOS
.