1、中国石油大学(华东)现代远程教育实验报告课程名称:微机原理及应用实验名称:循环程序设计实验形式:在线模拟+现场实践提交形式:在线提交实验报告学生姓名: 褚东 学 号:1796414800002 年级专业层次:17 电气自动化技术 高起专 学习中心: 山东枣庄函授站(新) 提交时间: 2018 年 7 月 10 日一、实验目的1掌握单重循环及多重循环的程序设计方法; 2学会针对不同的问题,选用不同的组织循环的方法; 3进一步熟悉利用 DEBUG 程序、CODEVIEW 调试程序的方法,并检查和验证结果的正确性。二 、实验内容1. 已知字数组定义如下:ARRAY DW 12,78,55,4,125
2、,96MAX DW ?编制程序求出该 ARRAY 数组中的最大数放入 MAX 单元。data segmentarray dw 12,78,55,4,125,96maxdw ?data endscode segmentassume cs:code,ds:datastart:movax,datamovds,axmovsi,0movax,arraysimovcx,5again:addsi,2deccxjcxz exitcmpax,arraysija againmovax,arraysijmpagainexit:movmax,axmovah,02hint21hmovah,4chint21hcode e
3、ndsendstart2. 预留字符串口令,输入口令串与预留密码串比较。若匹配则显示“MATCH!CONGRATULATION”,否则显示“NOMATCH!”,并让用户重新输入,程序能对口令进行测试,但测试次数最多 3 次,若 3 次输入密码皆错,给出相应的提示信息,程序退出。data segmentpassword db 123456input db 20,?,20 dup(?)count equ6str1 db 0dh,0ah,match!congratulation$str2 db 0dh,0ah,no match!please input again:$str3 db 0dh,0ah,
4、please intout you password:$str4 db 0dh,0ah,wrong 3 times,program will be over$data endscode segmentassume cs:code,ds:datastart: movax,datamovds,axmovdi,3begin:decdileadx,str3movah,09hint21hleadx,inputmovah,0ahint21hmovsi,0moval,inputsi+1cmpal,countjnzoutput1movsi,0movcx,countagain:moval,passwordsim
5、ovbl,inputsi+2cmpal,bljnzoutput1incsiloop againjmpoutput2output1:leadx,str2movah,09int21hcmpdi,0jnzbeginjmpaaoutput2:leadx,str1movah,09int21hjmpexitaa:leadx,str4movah,09int21hmovax,9999ha:movcx,9999hb:loop bdecaxjnzaexit:movah,4chint21hcode endsendstart3.有一个首地址为 NUM 的 N 字无序无符号整数数组,编制程序采用选择排序法使该数组中的数
6、按照从小到大的次序排序输出。data segmentarray dw 22,31,10,5,1,66,136,99data endscode segmentmain proc farassume cs:code,ds:datastart: movax,datamovds,axmovdi,0again:movsi,dinext:movax,arraydiaddsi,2cmpsi,16ja exitcmpax,arraysijbenextxchg ax,arraysimovarraydi,axjmpnextexit:adddi,2cmpdi,16jb againcall outputmovah,4
7、chint21hmain endpoutput proc nearpush axpush bxpush cxpush dxmovdi,0s0:movax,arraybxmovcx,sps1:movdx,0movdi,10divdipush dxcmpax,0ja s1s2:popaxaddax,30hmovdl,almovah,02hint21hcmpsp,cxjb s2addbx,2movdx,movah,02hint21hcmpbx,15jbes0popdxpopcxpopbxpopaxretoutput endpcode endsendstart4.设有一段英文,其字符变量名为 ENG,
8、并以$字符结束。试编写一程序,统计其中单词的个数,并查出单词 SUN 在该文中的出现次数,并以格式“SUN:”显示出次数。sta segment stackdw 40h dup(?)top label wordsta endsdatarea segment ENG db I ALWAYS WATCH THE NBA GAMES .ESPECIALLY I SUPPORT FOR THE SUN TEAM$total dw ?num db SUN:$datarea ends code segmentassume ds:datarea,ss:sta,cs:codemain proc farmov
9、ax,stamov ss,axlea sp,topmov ax,datareamov ds,axxor bx,bxxor ax,axmov si,0l0: mov al,ENGsicmp al,$je exitcmp al,Sjne gobackinc simov al,ENGsicmp al,Ujne gobackinc si mov al,ENGsicmp al,Njne gobackinc bxinc sijmp l0 goback:inc sijmp l0 exit: mov total,bxmov ah,09hlea cx,nummov dx,cxint 21hmov cx,4mov bx,totall11:push cxmov cl,4rol bx,clpush bxmov al,bland al,0fhcmp al,0jb l10cmp al,9jna rightadd al,7right:add al,30hmov dl,almov ah,2int 21hpop bxpop cxloop l11 l10:mov ah,4chint 21hmain endpcode ends