2016-05-15

微机系统与接口实验(八)—数码管显示实验

1. 实验目的

  • 学习“七段共阴极数码管”显示的基本原理。
  • 掌握通过并行接口芯片控制多个数码管显示的方法。

2. 实验内容

  • 题目1:使六位数码管从右到左逐位显示移动的数字0-9。
  • 题目2:使六位数码管从左到右显示稳定的数字“123456”。
  • 题目3:初始时数码管显示0,按下单脉冲开关KK1的次数为n,若1<=n<=6则在最左边的6-n个数码管上同时显示“0”,若n>6则程序退出。
  • 题目4:将开关K7-K0输入的二进制数转化为十进制数显示在最右侧的1-3个数码管上要求可以动态显示。

3. 实验1

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
122
123
124
125
126
;8255接口初始化,由CS连接的IOY端口决定。
A8255_CON EQU 0606H
A8255_A EQU 0600H
A8255_B EQU 0602H
A8255_C EQU 0604H
;数码管的数据表,分别表示0-9
DATA SEGMENT
TABLE1:
    DB 3FH
    DB 06H
    DB 5BH
    DB 4FH
    DB 66H
    DB 6DH
    DB 7DH
    DB 07H
    DB 7FH
    DB 6FH
DATA ENDS
CODE SEGMENT
    ASSUME CS:CODE,DS:DATA
START:
    MOV AX,DATA
    MOV DS,AX
    LEA SI,TABLE1
    MOV DX,A8255_CON
    MOV AL,81H
    OUT DX,AL
    MOV DX,A8255_B
    MOV AL,3FH
    OUT DX,AL
    MOV DX,A8255_A
    MOV AL,00H
    OUT DX,AL
    MOV CX,0AH
    MOV BX,0000H
X1: 
    PUSH CX
    MOV CX,06H
    MOV AL,11011111B
X2:
    MOV DX,A8255_A
    OUT DX,AL
    ROR AL,1
    PUSH AX
    MOV AL,[BX+SI]
    MOV DX,A8255_B
    OUT DX,AL
    POP AX
    CALL DELAY
    LOOP X2
    POP CX
    INC BX
    LOOP X1
    JMP START
DELAY:
    PUSH CX
    MOV CX,0FFFFH
X4:
    LOOP X4
    MOV CX,0FFFFH
X5:
    LOOP X5
    POP CX
    RET
CODE ENDS
     END START
</code>
 
<blockquote>4. 实验2</blockquote>
<code lang='asm'>
A8255_CON EQU 0606H
A8255_A EQU 0600H
A8255_B EQU 0602H
A8255_C EQU 0604H
 
DATA SEGMENT
TABLE1:
    DB 7DH
    DB 6DH
    DB 66H
    DB 4FH
    DB 5BH
    DB 06H
DATA ENDS
CODE SEGMENT
    ASSUME CS:CODE,DS:DATA
START:
    MOV AX,DATA
    MOV DS,AX
    LEA SI,TABLE1
    MOV DX,A8255_CON
    MOV AL,81H
    OUT DX,AL
    MOV DX,A8255_B
    MOV AL,3FH
    OUT DX,AL
    MOV DX,A8255_A
    MOV AL,00H
    OUT DX,AL
X2:    
    MOV CX,06H
    MOV BX,0000H
    MOV AL,11011111B
X1: 
    MOV DX,A8255_A
    OUT DX,AL
    ROR AL,1
    PUSH AX
    MOV AL,[BX+SI]
    MOV DX,A8255_B
    OUT DX,AL
    POP AX
    CALL DELAY
    INC BX
    LOOP X1
    JMP X2    
DELAY:
    PUSH CX
    MOV CX,0FFH
X4:
    LOOP X4
    POP CX
    RET
CODE ENDS
     END START

5. 实验3

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
A8255_CON EQU 0606H
A8255_A EQU 0600H
A8255_B EQU 0602H
A8255_C EQU 0604H
 
PUBLIC TIMES
DATA SEGMENT
TIMES DB 06H
DATA ENDS
 
CODE SEGMENT
    ASSUME CS:CODE,DS:DATA
START:
    MOV AX,DATA
    MOV DS,AX
    MOV AX, OFFSET MIR6
    MOV SI, 0038H
    MOV [ES:SI], AX
    MOV AX, CS
    MOV SI, 003AH
    MOV [ES:SI], AX
    CLI
    MOV AL, 11H
    OUT 20H, AL
    MOV AL, 08H
    OUT 21H, AL
    MOV AL, 04H
    OUT 21H, AL
    MOV AL, 01H
    OUT 21H, AL
    MOV AL, 3FH
    OUT 21H, AL
    STI
    MOV DX,A8255_CON
    MOV AL,81H
    OUT DX,AL
    MOV DX,A8255_B
    MOV AL,3FH
    OUT DX,AL
    MOV DX,A8255_A
    MOV AL,00H
    OUT DX,AL
MAIN:
    CMP TIMES,00H
    JE EXIT
    CALL LED
    JMP MAIN
EXIT:
    MOV AL,00H
    MOV DX,A8255_B
    OUT DX,AL
    MOV AH, 4CH
    INT 21H
MIR6:
    DEC TIMES
    PUSH AX
    MOV AL, 20H
    OUT 20H, AL
    POP AX
    IRET
LED:
X2:    
    MOV BX, OFFSET TIMES
    MOV CX, [BX]
    MOV BX, 0000H
    MOV AL, 11011111B
X1: 
    MOV DX,A8255_A
    OUT DX,AL
    ROR AL,1
    PUSH AX
    MOV AL,3FH
    MOV DX,A8255_B
    OUT DX,AL
    POP AX
    CALL DELAY
    LOOP X1
    RET
DELAY:
    PUSH CX
    MOV CX,0FFH
X4:
    LOOP X4
    POP CX
    RET
CODE ENDS
     END START

6. 实验4

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
A8255_CON EQU 0606H
A8255_A EQU 0600H
A8255_B EQU 0602H
A8255_C EQU 0604H
 
PUBLIC LED1
PUBLIC LED2
PUBLIC LED3
DATA SEGMENT
LED1 DB ?
LED2 DB ?
LED3 DB ?
TABLE1:
    DB 3FH
    DB 06H
    DB 5BH
    DB 4FH
    DB 66H
    DB 6DH
    DB 7DH
    DB 07H
    DB 7FH
    DB 6FH
DATA ENDS
 
CODE SEGMENT
    ASSUME CS:CODE,DS:DATA
START:
    MOV AX,DATA
    MOV DS,AX
    LEA SI,TABLE1
    MOV DX,A8255_CON
    MOV AL,89H
    OUT DX,AL
    MOV DX,A8255_B
    MOV AL,3FH
    OUT DX,AL
    MOV DX,A8255_A
    MOV AL,00H
    OUT DX,AL
X2:    
    MOV DX,A8255_C
    IN AL,DX
    MOV AH,00H
    MOV BL,0AH
    DIV BL
    MOV LED1, AH
    MOV AH,00H
    DIV BL
    MOV LED2, AH
    MOV AH,00H
    DIV BL
    MOV LED3, AH
    MOV CX,03H
    MOV BX,0000H
    MOV AL,11011111B
    MOV DX,A8255_A
    OUT DX,AL
    MOV BX,OFFSET LED1
    MOV BX,[BX]
    MOV BH,00H
    MOV AL,[BX+SI]
    MOV DX,A8255_B
    OUT DX,AL
    CALL DELAY
    MOV AL,00H
    OUT DX,AL
    MOV AL,11101111B
    MOV DX,A8255_A
    OUT DX,AL
    MOV BX,OFFSET LED2
    MOV BX,[BX]
    MOV BH,00H
    MOV AL,[BX+SI]
    MOV DX,A8255_B
    OUT DX,AL
    CALL DELAY
    MOV AL,00H
    OUT DX,AL
    MOV AL,11110111B
    MOV DX,A8255_A
    OUT DX,AL
    MOV BX,OFFSET LED3
    MOV BX,[BX]
    MOV BH,00H
    MOV AL,[BX+SI]
    MOV DX,A8255_B
    OUT DX,AL
    CALL DELAY
    MOV AL,00H
    OUT DX,AL
    JMP X2    
DELAY:
    PUSH CX
    MOV CX,0FFH
X4:
    LOOP X4
    POP CX
    RET
CODE ENDS
     END START
Share

You may also like...

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据