微机实验程序11Word格式文档下载.docx
《微机实验程序11Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《微机实验程序11Word格式文档下载.docx(27页珍藏版)》请在冰豆网上搜索。
![微机实验程序11Word格式文档下载.docx](https://file1.bdocx.com/fileroot1/2023-1/10/f66570a8-8bf6-486f-a429-dff7976c2f85/f66570a8-8bf6-486f-a429-dff7976c2f851.gif)
?
MOVDX,PORT;
OUTDX,AL
MOVAL,00;
送除数寄存器高8位,波特率9600B/S
MOVDX,PORT1;
MOVAL,00011011B;
MOVDX,PORT3;
MOVAL,00H
OUTDX,AL;
关闭8250所有中断
MOVDX,OFFSETMES;
显示提示信息
MOVAH,09H
INT21H
WAITI:
MOVDX,PORT5;
读线路状态寄存器(LCR)D1=RTS请求发送位测试
INAL,DX
ANDAL,20H
TESTAL,20H
JZWAITI
MOVAH,01;
读键盘ASC码
INT21H
CMPAL,’A’;
是ESC码吗?
是退出esc是27
JZEXIT
ESC码加1送发送口
INC/DECAL;
加1/减1(ADDAL,4加4/SUBAL,4减4)
MOVCX,40H;
延时
S50:
LOOPS50
NEXT:
MOVDX,PORT5;
读线路状态寄存器(LCR)D0=DTR数据终端准备好位测试
INAL,DX
ANDAL,01
TESTAL,01
JZNEXT
MOVDX,PORT;
读接收数据寄存器(RDR),并显示
INAL,DX
MOVDL,AL
MOVAH,02
JMPWAITI
EXIT:
MOVAH,4CH
CODEENDS
ENDSTART
实验八——可编程定时器计数器8253
(一)
1
2
3
4
5
10h
12h
14h
16h
18h
1Ah
50h
52h
54h
56h
58h
5Ah
90h
92h
94h
96h
98h
9Ah
实验现象是FFFFFFF987654321987654321按钮同时操作
ioportequ0d880h-0280h
io8253_0equioport+280h;
选择的端口地址280-?
io8253_1equioport+281h
io8253_2equioport+282h
io8253_ctlequioport+283h
codesegment
assumecs:
code
start:
moval,14h;
设置8253通道0为工作方式2,二进制计数00100100p274
movdx,io8253_ctl;
地址
outdx,al
movdx,io8253_0;
送计数初值为0FH
moval,09h;
设置8253通道0为工作方式4,BCD计数00001001p274
outdx,al
lll:
inal,dx;
读计数初值
calldisp;
调显示子程序
pushdx
movah,06h
movdl,0ffh
int21h
popdx
jzlll
movah,4ch;
退出
int21h
dispprocnear;
显示子程序
pushdx
andal,0fh;
首先取低四位
movdl,al
cmpdl,9;
判断是否<
=9
jlenum;
若是则为'
0'
-'
9'
ASCII码加30H
adddl,7;
否则为'
A'
F'
ASCII码加37H
num:
adddl,30h
movah,02h;
显示
movdl,0dh;
加回车符
movdl,0ah;
加换行符
ret;
子程序返回
dispendp
codeends
endstart
实验九——可编程定时器计数器8253
(二)
现象:
地址口下的两个等交替闪烁
io8253_0equioport+280h如果要0计数器的话
io8253_1equioport+281h;
io8253_2equioport+282h
movdx,io8253_ctl;
向8253写控制字
moval,76h;
使1通道为工作方式301110110
outdx,al
movax,50000;
写入循环计数初值?
(1Mhz/20hz)
movdx,io8253_1;
通道1计数器1
outdx,al;
先写入低字节
moval,ah
后写入高字节
movdx,io8253_ctl
moval,0B6h;
设8253通道2工作方式310110110
movax,40;
(20hz/0.5hz)
movdx,io8253_2;
通道2计数器2
先写低字节
后写高字节
程序退出
endstart
实验十——8255A并行接口应用实验
(一)
现象开关一个个打开后,灯依次一个一个亮
设8255为C口输入,A口输出,所谓的输入是和开关相连的口,输出是与灯相连的口
io8255aequioport+288h;
PA口;
选择的端口地址288-?
io8255bequioport+289h;
PB口
io8255cequioport+28ah;
PC口
io8255_ctlequioport+28Bh;
movdx,io8255_ctl
;
设8255为C口输入,A口输出
moval,89h;
1000(A口输出为0)1(PC口作输入1)001(PC口作输入1)P291
inout:
movdx,io8255c;
PC口作输入从PC口输入一数据开关
inal,dx
movdx,io8255a;
PA口作输入从PA口输出刚才自C口灯泡
所输入的数据
movdl,0ffh;
判断是否有按键
movah,06h
jzinout;
若无,则继续自C口输入,A口输出
否则返回DOS
codeends
PA口输入PB口输出
io8255aequioport+290h;
选择的端口地址290-?
io8255bequioport+291h
io8255cequioport+292h
io8255_ctlequioport+293h
movdx,io8255_ctl
设8255为a口输入,b口输出
moval,90h1001(A口输入)000(B口输出)0P291
movdx,io8255a;
从a口输入一数据开关
movdx,io8255b;
从b口输出刚才自a口灯泡OR二极管
若无,则继续自a口输入,b口输出
实验十一8255应用
(二)模拟交通灯
?
datasegment
io8255bequioport+289h
io8255cequioport+28ah
io8255_ctlequioport+28bh
portc1db84h,24h,44h,04h,44h,04h,44h,04h;
六个灯可能
db81h,82h,80h,82h,80h,82h,80h;
的状态数据
db0ffh;
结束标志
dataends
code,ds:
data
movax,data
movds,ax
movdx,io8255_ctl
moval,90h;
1001(有A口输入吗?
)0000P291
outdx,al
movdx,io8255c;
设置8255为PC口输出
re_on:
movbx,0
on:
moval,portc1[bx]
cmpal,0ffh
jzre_on
点亮相应的灯
incbx
testal,21h;
是否有绿灯亮00100001
jzdel;
没有,短延时
calldel30
jmpdel1
del:
calldel05
del1:
pushdx
movah,06h;
00000110
jzon;
没有,转到on
exit:
返回00000100
del05procnear
pushax
pushcx
movcx,07h
movdx,0a120h
movah,86h;
10000110
int15h
popcx
popax
ret
del05endp
del30procnear
movcx,1c9h
movdx,0C380h
movah,86h
del30endp
实验十二——模/数转换器(8090与8255的结合)
现象是转动可调那个啥,二极管闪烁无定,并且屏幕上全是变动的数字
io0809_0equioport+298h;
AD转换器端口地址298-
io0809_1equioport+299h
io0809_2equioport+29Ah
io0809_3equioport+29Bh
io0809_4equioport+29Ch
io0809_5equioport+29Dh
io0809_6equioport+29Eh
io0809_7equioport+29Fh
io8255aequioport+290h;
8255端口地址290-
io8255bequioport+291h
io8255cequioport+292h
io8255_ctlequioport+293h
movdx,io8255_ctl;
8255初始化
moval,80h
movdx,io0809_0;
启动A/D转换器就是他器件下面的IN(0,1,…)IN0调的滚轮
movcx,04ffh;
delay:
loopdelay
从A/D转换器输入数据
movdx,io8255c;
送8255PC口输出灯泡的位置
outdx,al
movbl,al;
将AL保存到BL
movcl,4
shral,cl;
将AL右移四位
calldisp;
调显示子程序显示其高四位
moval,bl
andal,0fh
调显示子程序显示其低四位
movah,02
movdl,20h;
movdl,20h
判断是否有键按下
jestart;
若没有转START
movdl,al
比较DL是否>
9
jleddd;
若不大于则为'
加30h为其ASCII码
adddl,7;
再加7
ddd:
adddl,30h;
dispendp
输出有高低电平之分也就是PC口和PBorPA口输出
io0809_0equioport+2a8h
io0809_1equioport+2a9h
io0809_2equioport+2aah
io0809_3equioport+2abh
io0809_4equioport+2ach
io0809_5equioport+2adh
io0809_6equioport+2aeh
io0809_7equioport+2afh
io8255ctlequioport+293h
io8255aequioport+290h
movdx,io8255ctl;
movdx,io0809_6;
启动A/D转换器
送8255C口就是高低电平的问题所在,上下在8255那里
movdx,io8255b
实验十三——数/模转换器0832
现象是示波器上有方波。
用CT2端口
io0832aequioport+290h
movdx,io0832a
moval,0d0h;
貌似是3v这些要自己测出来的
calldelay25
moval,30h;
貌似是-3v
返回
delay25procnear
movcx,00h
movdx,2561
delay25endp
综合实验
现象按钮依次按下,二极管从最右边开始依次亮起
int_vectEQU073H;
中断0-7的向量为:
08h-0fh,中断8-15的向量为:
70h-77h
irq_mask_2_7equ011111011b;
中断掩码,中断0-7时从低至高相应位为零,中断8-15时第2位为零
irq_mask_9_15equ011110111b;
中断0-7时全一,中断8-15时从低至高相应位为零
ioport_dataequ0d880h-280h;
tpc卡中设备的io地址
ioport_centequ0dC00h;
tpc卡中9054芯片的io地址
csregdw?
ipregdw?
旧中断向量保存空间
portoutdw00h;
中断计数
msg1db0dh,0ah,'
TPCpcicardInterrupt'
0dh,0ah,'
msg2db0dh,0ah,'
Pressanykeytoexit!
msg3db0dh,0ah,'
PressDMCtointerrupt8timesandexit!
stackssegment
db100dup(?
)
stacksends
data,ss:
stacks,es:
.386
cli
moves,ax
movax,stacks
movss,ax
movdx,ioport_cent+68h;
设置tpc卡中9054芯片io口,使能中断
inax,dx
orax,0900h
outdx,ax
moval,int_vect;
保存原中断向量
movah,35h
movax,es
movcsreg,ax
movipreg,bx
movax,cs;
设置新中断向量
movdx,offsetint_proc
moval,int_vect
movah,25h
inal,21h;
设置中断掩码
andal,irq_mask_2_7
out21h,al
inal,0a1h
andal,irq_mask_9_15
out0a1h,al
movdx,offsetmsg2
movah,09h
movdx,offsetmsg3
mov