-
Notifications
You must be signed in to change notification settings - Fork 0
/
7_3_3.asm
121 lines (101 loc) · 1.89 KB
/
7_3_3.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
NAME EX_7_3_2
DATA SEGMENT
KEEPIP DW 0
KEEPCS DW 0
DATA ENDS
STACK SEGMENT
DB 100 DUP(?)
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,ES:DATA,SS:STACK
START:
MOV AX,DATA
MOV DS,AX
MOV ES,AX
; set 8253
MOV DX,293H
MOV AL,00110111B
OUT DX,AL
MOV DX,290H
MOV AL,90
OUT DX,AL
OUT DX,AL
; set 8255
MOV DX,283H ; set control word
MOV AL,10000000B
OUT DX,AL
; change interrupt vector
MOV AH,35H ; get the add of interrupt vector
MOV AL,0BH
INT 21H
MOV KEEPIP,BX ; protect the interrupt vector
MOV KEEPCS,ES
PUSH DS ; change the interrupt vector
MOV DX,OFFSET INTR
MOV AX,SEG INTR
MOV DS,AX
MOV AH,25H
MOV AL,0BH
INT 21H
POP DS
; cancel the mask of IRQ3
IN AL,21H
AND AL,011110111B
OUT 21H,AL
MOV BL,0
MAIN: ; iterate
HLT
MOV AH,1
INT 16H ; if keyboard inputs, exit
JNE EXIT
JMP MAIN
EXIT:
; restore the mask of IRQ3
IN AL,21H
OR AL,00001000B
OUT 21H,AL
; restore interrupt vector
PUSH DS
MOV DX,KEEPIP
MOV AX,KEEPCS
MOV DS,AX
MOV AH,25H
MOV AL,0BH
INT 21H
POP DS
MOV AH,4CH ; return to DOS
INT 21H
INTR PROC ; interrupt vector
; shutdown two digits
MOV DX,282H
MOV AL,00H
OUT DX,AL
CMP BL,0
JNZ OUT1
OUT0:
MOV DX,280H
MOV AL,3FH
OUT DX,AL ; port A output
MOV DX,282H
MOV AL,01H
OUT DX,AL
MOV BL,1
JMP END_INTR
OUT1:
; output 1
MOV DX,280H
MOV AL,06H
OUT DX,AL
MOV DX,282H
MOV AL,02H
OUT DX,AL
MOV BL,0
JMP END_INTR
END_INTR:
MOV AL,20H ; send out EOI
OUT 0A0H,AL
OUT 20H,AL
IRET
INTR ENDP
CODE ENDS
END START