您好,欢迎访问三七文档
实验四汇编程序编写和提高(编写程序和画程序流程图)1、编写一个汇编程序,先键盘输入的多个小写字母,回车后用大写字母显示出来。程序:DATASSEGMENTbufdb100dup(?)DATASENDSSTACKSSEGMENT;此处输入堆栈段代码STACKSENDSCODESSEGMENTASSUMECS:CODES,DS:DATAS,SS:STACKSSTART:MOVAX,DATASMOVDS,AXleasi,bufconvert:movah,1int21hcmpal,13jzfinishcmpal,'a'jbnextcmpal,'z'janextsubal,20hjmpnextnext:mov[si],alincsijmpconvertfinish:movdl,13movah,2int21hmovdl,10int21hmovbyteptr[si],'$'leadx,bufmovah,9int21hMOVAH,4CHINT21HCODESENDSENDSTART运行情况:流程图:开始把buf的地址送到si输入字符输入回车?结束Y输入字符小于a?N把字符送到bufYSi指向下一个地址输入字符大于z?NYASCII码加32N回车换行给buf加结束标志$显示buf中的字符串2、将键盘上输入的十六进制数转换成十进制数,并在屏幕上显示。程序:DATASEGMENTDATA1DB6DUP(?),'$'DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVDI,OFFSETDATA1+5MOVBX,0MOVCH,4MOVCL,4MOVSI,0AHJUDGE:MOVAH,01HINT21HCMPAL,13JETRANSPORTCMPAL,30HJBEXITCMPAL,39HJBELABCMPAL,41HJBEXITCMPAL,46HJBELAB1CMPAL,61HJBEXITCMPAL,66HJAEXITSUBAL,57HJMPLAB2LAB:SUBAL,30HJMPLAB2LAB1:SUBAL,37HLAB2:SHLBX,CLADDBL,ALDECCHJNZJUDGETRANSPORT:MOVAX,BXDISPLAY:XORDX,DXDIVSIADDDL,30HMOV[DI],DLDECDICMPAX,0JNZDISPLAYXORDX,DXMOVAH,09HINT21HEXIT:MOVAH,4CHINT21HCODEENDSENDSTART运行情况:流程图:开始定义6字节数据段DI指向数据段最后输入数据输入回车?把输入的十六进制数送到AX作被除数Y输入小于0?结束NY输入小于等于9?输入数值减30HYBX左移4位数据放到BL里十六进制位数下降1位N输入小于A?NY输入小于等于F?N减去37HY输入小于a?NY输入大于f??NY减去57H输入了4位?NN把DX清零YAX的值除以10DL加30H把DL的值放入数据段数据段指向下一位数据商为0?N把DX清零Y输出字符串3、利用中断调用,在屏幕上显示1—9之间随机数。中断号86H程序如下:DATASSEGMENT;此处输入数据段代码DATASENDSSTACKSSEGMENT;此处输入堆栈段代码STACKSENDSCODESSEGMENTASSUMECS:CODES,DS:DATAS,SS:STACKSSTART:MOVAX,DATASMOVDS,AXcallsetInt86int86hMOVAH,4CHINT21HsetInt86procmovax,csmovds,axmovsi,offsetdo0movax,0moves,axmovdi,200hmovcx,offsetdo0end-offsetdo0cldrepmovsbmovax,0moves,axmovwordptres:[86h*4],200hmovwordptres:[86h*4+2],0retsetInt86endpdo0:MOVAH,0INT1AH;读取当前时间CH:CL=时:分MOVAL,DL;DH:DL=秒:1/100秒MOVAH,0MOVBL,9DIVBLINCAHMOVDL,AHADDDL,30HMOVAH,2INT21Hdo0end:nopCODESENDSENDSTART运行情况:流程图:开始设置源地址设置目的地址设置cx为传输长度设置传输方向为正设置中断向量表读取当前时间取出当前时间的1/100秒部分除以9显示数值调用中断结束4、键盘输入10个学生的成绩,编写一个程序统计60-69分,70-79分,80-89分,90-99分及100分的人数,分别存放在Score6,Score7,Score8,Score9和Score10单元中。【输入10个学生的成绩如下】659878828895726290100程序如下:datassegmentsentencedb0DH,0AH,'theresult$'gradedw76,69,84,90,73,88,99,63,100,80score6db0score7db0score8db0score9db0score10db0datasendsstackssegmentstacksendscodessegmentassumecs:codes,ds:datasstart:movax,datasmovds,axmovcx,10callcountcalldispmovah,4chint21hcountprocnearmovsi,0next:movax,grade[si]movbl,10divblmovbl,almovbh,0subbx,6cmpbx,0jaenext1next1:incscore6[bx]addsi,2loopnextretcountendpdispprocnearleasi,score6movcx,5loop1:movdx,OFFSETsentencemovah,9int21hmovdl,[si]adddl,30hmovah,2int21hincsilooploop1retdispendpcodesendsendstart效果如下:流程图:开始指定存放成绩的地址取成绩取十位给相应的计数区加1指向下一个数十个数判断完?N输出score里的数Y输出完5组?N结束Y
本文标题:汇编程序编写和提高
链接地址:https://www.777doc.com/doc-4561186 .html