您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > 其它相关文档 > 计算机原理小学期实验报告
DA及AD转换实验报告自03张驰昱20100120281、D/A转换用DAC0832实现D/A转换,使产生的模拟电压波形分别为锯齿波,三角波和正弦波要求:程序运行后等待键入(1)若键入‘1’,则产生锯齿波(2)若键入‘2’,则产生三角波(3)若键入‘3’,则产生正弦波(4)若键入‘4’,则返回DOS程序运行过程中没有新键入别的数字,则维持原状不变,用示波器能观测到连续的电压波形。解决思路:先写三个用于波形发生的过程,分别发出锯齿波、三角波和正弦波。再写一个每次从DAC0832输出数据前都会调用的产生延迟的过程,在这个过程中进行有无按键的判断和分辨按键的判断。主程序先调用这个延迟的过程,这样程序一旦运行起来就相当于不断的在检测按键了。正弦波的值我是通过matlab生成和写入文件,并保存在数据段里的。以下是生成一个周期256个采样sin值的matlab代码:clear;clc;fid=fopen('sine.txt','w');s=round(sin(2*pi/256*[1:256])*127.5+127.5);s=reshape(s,16,16);fori=1:16fprintf(fid,'DB');fprintf(fid,'%03XH,',s(:,i));fprintf(fid,'\n');end源代码:DATASSEGMENTDNUMDB01HCSADDDW0280HHINT1DB'TEETHWAVE',0DH,0AH,'$'HINT2DB'TRIANGLEWAVE',0DH,0AH,'$'HINT3DB'SINEWAVE',0DH,0AH,'$'SINEDB083H,086H,089H,08CH,08FH,092H,095H,098H,09BH,09EH,0A2H,0A5H,0A7H,0AAH,0ADH,0B0HDB0B3H,0B6H,0B9H,0BCH,0BEH,0C1H,0C4H,0C6H,0C9H,0CBH,0CEH,0D0H,0D3H,0D5H,0D7H,0DAHDB0DCH,0DEH,0E0H,0E2H,0E4H,0E6H,0E8H,0EAH,0EBH,0EDH,0EEH,0F0H,0F1H,0F3H,0F4H,0F5HDB0F6H,0F8H,0F9H,0FAH,0FAH,0FBH,0FCH,0FDH,0FDH,0FEH,0FEH,0FEH,0FFH,0FFH,0FFH,0FFHDB0FFH,0FFH,0FFH,0FEH,0FEH,0FEH,0FDH,0FDH,0FCH,0FBH,0FAH,0FAH,0F9H,0F8H,0F6H,0F5HDB0F4H,0F3H,0F1H,0F0H,0EEH,0EDH,0EBH,0EAH,0E8H,0E6H,0E4H,0E2H,0E0H,0DEH,0DCH,0DAHDB0D7H,0D5H,0D3H,0D0H,0CEH,0CBH,0C9H,0C6H,0C4H,0C1H,0BEH,0BCH,0B9H,0B6H,0B3H,0B0HDB0ADH,0AAH,0A7H,0A5H,0A2H,09EH,09BH,098H,095H,092H,08FH,08CH,089H,086H,083H,080HDB07CH,079H,076H,073H,070H,06DH,06AH,067H,064H,061H,05DH,05AH,058H,055H,052H,04FHDB04CH,049H,046H,043H,041H,03EH,03BH,039H,036H,034H,031H,02FH,02CH,02AH,028H,025HDB023H,021H,01FH,01DH,01BH,019H,017H,015H,014H,012H,011H,00FH,00EH,00CH,00BH,00AHDB009H,007H,006H,005H,005H,004H,003H,002H,002H,001H,001H,001H,000H,000H,000H,000HDB000H,000H,000H,001H,001H,001H,002H,002H,003H,004H,005H,005H,006H,007H,009H,00AHDB00BH,00CH,00EH,00FH,011H,012H,014H,015H,017H,019H,01BH,01DH,01FH,021H,023H,025HDB028H,02AH,02CH,02FH,031H,034H,036H,039H,03BH,03EH,041H,043H,046H,049H,04CH,04FHDB052H,055H,058H,05AH,05DH,061H,064H,067H,06AH,06DH,070H,073H,076H,079H,07CH,07FHDATASENDSSTACKSSEGMENTSTACKDW100DUP(?)STACKSENDSCODESSEGMENTASSUMECS:CODES,DS:DATAS,SS:STACKSDELAYPROC;延时子程序PUSHDXPUSHAXMOVAH,0BH;检测键盘有无按键,不等待INT21HCMPAL,0FFH;如果没有按键,继续JNZCONTINUEMOVAH,01H;如果有按键,读取键盘缓冲区的值并回显INT21HCMPAL,'1'JNZDUECALLTEETH;如果是1,调用锯齿波DUE:CMPAL,'2'JNZTRECALLTRI;如果是2,调用三角波TRE:CMPAL,'3'JNZQUACALLSIN;如果是3,调用正弦波QUA:CMPDL,'4';如果是4,退出JZEXITEXIT:MOVAX,4C00HINT21HCONTINUE:MOVDL,DNUM;如果无按键,那么哪里调用的就返回到哪里去L:DECDLJNZLPOPAXPOPDXRETDELAYENDPTRIPROC;三角波子程序PUSHAXPUSHDXLEADX,HINT1MOVAH,09HINT21HMOVAH,0FFHDOWN:CALLDELAY;三角波下降过程MOVAL,AHMOVDX,0280HOUTDX,ALCMPAH,1JEUPSUBAH,2JMPDOWNUP:CALLDELAY;三角波上升过程MOVAL,AHMOVDX,0280HOUTDX,ALCMPAH,0FFHJEDOWNADDAH,2JMPUPPOPDXPOPAXRETTRIENDPTEETHPROC;锯齿波子程序PUSHAXPUSHDXLEADX,HINT2MOVAH,09HINT21HPEAK:MOVAH,0FFH;我写的是一个下降的锯齿波Z:CALLDELAYMOVAL,AHMOVDX,0280HOUTDX,ALCMPAH,0JEPEAKDECAHJMPZPOPDXPOPAXRETTEETHENDPSINPROC;正弦波子程序PUSHDIPUSHSIPUSHAXPUSHDXLEADX,HINT3MOVAH,09HINT21HLEADI,SINEADDDI,0FFH;相当于用一个指针取顺序的扫描数据段里的数据HEAD:LEASI,SINE;扫描到结尾了再返回到开头TAIL:CALLDELAYMOVAL,[SI]MOVDX,0280HOUTDX,ALCMPSI,DIJEHEADINCSIJMPTAILPOPDXPOPAXPOPSIPOPDIRETSINENDPSTART:MOVAX,DATASMOVDS,AXCALLDELAY;主程序一开始就不断调用DELAY检查有无按键JMPSTARTCODESENDSENDSTART2、A/D转换用ADC0809实现A/D转换,用汇编语言程序自动对一个模拟信号重复采集20组不同的数据,在CRT上将每组数据对应显示成如下形式:D/AA/Dxxxx……然后等待键盘输入,若键入字母C则接着往下再做20组数据;若键入字母E则退回DOS。输入字母大小写应能兼容。源代码:DATASSEGMENTDNUMDW0FFFFHTDB0DH,0AH,'D/AA/D',0DH,0AH,'$';标题D/AA/DBLANKDB'','$';三个空格,为了与上面标题对对齐ENTDB0DH,0AH,'$';回车加换行DATASENDSSTACKSSEGMENTSTACKDW20DUP(?)STACKSENDSCODESSEGMENTASSUMECS:CODES,DS:DATAS,SS:STACKSDELAYMACRO;延时子程序LOCALNPUSHDXMOVDX,DNUMN:DECDXJNZNPOPDXENDMPLAYMACROSEG;显示AL寄存器十六进制值的子程序,这个子程序我在实验三中写过LOCALA2LOCALA1PUSHCXPUSHDXPUSHAXMOVDL,SEGANDDL,0F0H;取前四位MOVCL,4SHRDL,CLCMPDL,09HJBEA1ADDDL,07HA1:ADDDL,30HPUSHAXMOVAH,02H;输出前四位INT21HPOPAXMOVDL,SEGANDDL,0FH;取后四位CMPDL,09HJBEA2ADDDL,07HA2:ADDDL,30HMOVAH,02H;输出后四位INT21HPOPAXPOPDXPOPCXENDMSTART:MOVAX,DATASMOVDS,AXMOVCH,0AGAIN:MOVCL,20LEADX,TMOVAH,09HINT21HNEXT:PLAYCH;显示转换前的数字值MOVAL,CH;数模转换MOVDX,280HOUTDX,ALLEADX,BLANK;输出空格MOVAH,09HINT21HDELAYMOVAL,0;模数转换MOVDX,0289HOUTDX,ALDELAYJMPGO;这里三行只是一个中途的跳板,因为程序过长,JMP超出限度JUMP:JMPNEXTAGA:JMPAGAINGO:MOVDX,0289H;读入AD结果INAL,DXPLAYAL;输出AD结果LEADX,ENT;输出回车MOVAH,09HINT21HADDCH,0FH;每两个值相隔0FHDECCLJNZJUMPREAD:MOVAH,01H;检查键盘INT21HCMPAL,'E';E退出JEEXITCMPAL,'e’JEEXITCMPAL,'C';C继续读JNEREADCMPAL,'c'JNEREADJMPAGAEXIT:MOVAX,4C00HINT21HCODESENDSENDSTART计算机原理应用综合实验报告自03张驰昱20100120281、方式0I/O将TPC实验台上的8255电路A口设置成方式0输入,检测8只开关的状态;将C口设置成方式0输出,控制8只LED灯。程序运行后不断地读入8只开关的状态,送往对应的LED灯显示,直至在计算机键盘上敲入空格键退回DOS。源代码:codesegmentassumecs:codeSTART:MOVAL,10010000B;写控制字MOVDX,0283HOUTDX,ALAGAIN:MOVDX,0280H;从A口输入INAL,DXMOVDX,0282H;C口输出OUTDX,ALMOVAH,0BH;检查键盘有无按键,不等待INT21HCMPAL,0FFH;如果有按键,去检查是不是空格JEEXITJMPAGAIN;如果无按键,继续EXIT:MOVAH,01HINT21HCMPAL,''JNEAGAINmovax,4c00hint21hcodeendsendstart2、选作内容A口仍保持方式0输入开关状态,C口仍以方式0输出LED灯显示,满足如下条件:(1)若仅K7=1,8只LED的状态循环左移(2)若仅K6=1,8只LED的状态循环右移(3)若仅K6=K7,8只LED一起闪烁。源代码:codesegmentassumecs:codeDELAYMACRO;延时子程序LOCALNPUSHDXMOVDX,0FFFFHN:DECDXJNZNPOPDXENDMHOLDMACRO;发现一次0FFFFH的计数不够长,四次够长了,五次的话JMP就超限了DELAYDELAYDELAYDELAYENDMLE
本文标题:计算机原理小学期实验报告
链接地址:https://www.777doc.com/doc-3675251 .html