1八个硬件实验实验三简单并行接口(输入)实验一.实验目的掌握简单并行接口的工作原理及使用方法。二.实验内容见实验报告三.参考程序(文件名:74LS244.ASM)IOPORTEQU0DC00H-0280HIS244EQUIOPORT+2A0HCODESEGMENTASSUMECS:CODESTART:MOVDX,IS244;从2A0H输入一数据INAL,DXMOVDL,AL;将所读数据保存在DL中MOVAH,02HINT21HMOVDL,0DH;显示回车符INT21HMOVDL,0AH;显示换行符INT21HMOVAH,06H;有键按下吗?MOVDL,0FFHINT21HJNZEXITJESTART;若无,则转STARTEXIT:MOVAH,4CH;返回DOSINT21HCODEENDSENDSTART2实验四简单并行接口(输出)实验一.实验目的掌握简单并行接口的工作原理及使用方法。二.实验内容见实验报告册三.参考程序(文件名:74LS273.ASM)IOPORTEQU0DC00H-0280HIS273EQUIOPORT+2A8HCODESEGMENTASSUMECS:CODESTART:MOVAH,02H;回车符MOVDL,0DHINT21HMOVAH,01H;等待键盘输入INT21HCMPAL,27;判断是不是ESC键JEEXIT;若是ESC键,则退出MOVDX,IS273;若不是ESC键,从280HOUTDX,AL;输出其ASCII码JMPSTART;转STARTEXIT:MOVAH,4CH;返回DOSINT21HCODEENDSENDSTART3实验五七段数码管(8255)实验一.实验目的掌握数码管显示数据的原理。二.实验内容见实验报告册三.参考程序(文件名:LED1.ASM)datasegmentioportequ0DC00h-0280hio8255aequioport+288hio8255bequioport+28bhleddb3fh,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fhmesg1db0dh,0ah,'Inputanum(0--9h):',0dh,0ah,'$'dataendscodesegmentassumecs:code,ds:datastart:movax,datamovds,axmovdx,io8255b;使8255的A口为输出方式movax,80houtdx,alsss:movdx,offsetmesg1;显示提示信息movah,09hint21hmovah,01;从键盘接收字符int21hcmpal,'0';是否小于0jlexit;若是则退出cmpal,'9';是否大于9jgexit;若是则退出subal,30h;将所得字符的ASCII码减30Hmovbx,offsetled;bx为数码表的起始地址xlat;求出相应的段码movdx,io8255a;从8255的A口输出outdx,aljmpsss;转SSSexit:movah,4ch;返回DOSint21hcodestart4实验六交通灯控制实验一.实验目的通过并行接口8255实现十字路口交通灯的模拟控制,进一步掌握对并行口的使用。二.实验内容见实验报告册三.参考程序(文件名:JTD.ASM)DATASEGMENTIOPORTEQU0DC00H-0280HIO8255AEQUIOPORT+28AHIO8255BEQUIOPORT+28BHPORTC1DB24H,44H,04H,44H,04H,44H,04H;六个灯可能DB81H,82H,80H,82H,80H,82H,80H;的状态数据DB0FFH;结束标志DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDX,AXMOVDX,IO8255BMOVAL,90HOUTDX,AL;设置8255为C口输出MOVDX,IO8255ARE_ONMOVBX,0ON:MOVAL,PORTC1[BX]CMPAL,0FFHJZRE_ONOUTDX,AL;点亮相应的灯INCBXMOVCX,20;参数赋初值TESTAL,21H;是否有绿灯亮JZDE1;没有,短延时MOVCX,2000DE1:MOVDI,9000;DI赋初值9000DE0:DECDI;减1计数JNZDE0;DI不为0,继续延时LOOPDE1PUSHDXMOVAH,06HMOVDL,0FFHINT21HPOPDXJZON;没有,转到ONEXIT:MOVAH,4CH;返回DOSINT21HCODEENDSENDSTART5实验七可编程定时器/计数器(8253-1)实验一、实验目的:掌握8253的基本工作原理和编程方法。二.实验内容:见实验报告册三.参考程序(文件名:E8253_1.ASM)ioportequ0DC00h-0280hio8253aequioport+283hio8253bequioport+280hcodesegmentassumecs:codestart:moval,14h;设置8253通道0为工作方式2,二进制计数movdx,io8253aoutdx,almovdx,io8253b;送计数初值为0FHmoval,0fhoutdx,allll:inal,dx;读计数初值calldisp;调显示子程序pushdxmovah,06hmovdl,0ffhint21hpopdxjzlllmovah,4ch;退出int21hdispprocnear;显示子程序pushdxandal,0fh;首先取低四位movdl,alcmpdl,9;判断是否=9jlenum;若是则为'0'-'9',ASCII码加30Hadddl,7;否则为'A'-'F',ASCII码加37Hnum:adddl,30hmovah,02h;显示int21hmovdl,0dh;加回车符int21hmovdl,0ah;加换行符int21hpopdxret;子程序返回dispendpcodeendsendstart6实验八可编程定时器/计数器(8253-2)实验一、实验目的掌握8253的基本工作原理和编程方法。二、实验内容按图7连接电路,将计数器0、计数器1分别设置为方式3,计数初值设为1000,用逻辑笔观察OUT1输出电平的变化(频率1HZ)三、编程提示8253控制寄存器地址283H计数器0地址280H计数器1地址281HCLK0连接时钟1MHZ四.参考程序如下:(文件名:E8253_2.ASM)ioportequ0DC00h-0280hio8253aequioport+280hio8253bequioport+281hio8253cequioport+283hcodesegmentassumecs:codestart:movdx,io8253c;向8253写控制字moval,36h;使0通道为工作方式3outdx,almovax,1000;写入循环计数初值1000movdx,io8253aoutdx,al;先写入低字节moval,ahoutdx,al;后写入高字节movdx,io8253cmoval,76h;设8253通道1工作方式2outdx,almovax,1000;写入循环计数初值1000movdx,io8253boutdx,al;先写低字节moval,ahoutdx,al;后写高字节movah,4ch;程序退出int21hcodeendsendstart7实验九模/数转换实验一.实验目的:了解模/数转换的基本原理,掌握ADC0809的使用方法。二.实验内容:见实验报告册三.参考程序如下:(文件名:ADC1.ASM)ioportequ0dC00h-0280hio0809aequioport+298hcodesegmentassumecs:codestart:movdx,io0809a;启动A/D转换器outdx,almovcx,0ffh;延时delay:loopdelayinal,dx;从A/D转换器输入数据movbl,al;将AL保存到BLmovcl,4shral,cl;将AL右移四位calldisp;调显示子程序显示其高四位moval,blandal,0fhcalldisp;调显示子程序显示其低四位movah,02movdl,20h;加回车符int21hmovdl,20hint21hpushdxmovah,06h;判断是否有键按下movdl,0ffhint21hpopdxjestart;若没有转STARTmovah,4ch;退出int21hdispprocnear;显示子程序movdl,alcmpdl,9;比较DL是否9jleddd;若不大于则为'0'-'9',加30h为其ASCII码adddl,7;否则为'A'-'F',再加7ddd:adddl,30h;显示movah,02int21hretdispendpcodeendsendstart8实验十数模转换实验1程序清单(锯齿波)一.实验目的了解数/模转换器的基本原理,掌握DAC0832芯片的使用方法。二.实验内容1.实验电路原理如图11,DAC0832采用单缓冲方式,具有单双极性输入端(图中的Ua、Ub),用万用表测量单极性输出端Ua及双极性输出端Ub的电压,验证数字与电压之间的线性关系。2.编程产生以下波形(从Ub输出,用示波器观察)三.产生锯齿波的参考程序如下:(文件名:DAC1.ASM)ioportequ0dC00h-0280hio0832aequioport+290hcodesegmentassumecs:codestart:movcl,0movdx,io0832alll:moval,cloutdx,alinccl;cl加1incclincclincclincclincclincclpushdxmovah,06h;判断是否有键按下movdl,0ffhint21hpopdxjzlll;若无则转LLLmovah,4ch;返回DOSint21hcodeendsendstart9数模转换实验2程序清单(正弦波)产生正弦波的参考程序如下:(文件名:DAC2.ASM)datasegmentioportequ0dC00h-0280hio0832aequioport+290hsindb80h,96h,0aeh,0c5h,0d8h,0e9h,0f5h,0fdhdb0ffh,0fdh,0f5h,0e9h,0d8h,0c5h,0aeh,96hdb80h,66h,4eh,38h,25h,15h,09h,04hdb00h,04h,09h,15h,25h,38h,4eh,66h;正弦波数据dataendscodesegmentassumecs:code,ds:datastart:movax,datamovds,axll:movsi,offsetsin;置正弦波数据的偏移地址为SImovbh,32;一组输出32个数据lll:moval,[si]movdx,io0832aoutdx,al;将数据输出到D/A转换器movah,06hmovdl,0ffhint21hjneexitmovcx,1delay:loopdelay;延时incsi;取下一个数据decbhjnzlll;若未取完32个数据则转LLLjmpllexit:movah,4ch;返回DOSint21hcodeendsendstart