您好,欢迎访问三七文档
1.编制程序计算S=1+2+3+4+……+N直到和大于500为止,并将结果在屏幕上显示出来(N的值和最终的和的值)。DATASEGMENTNDW?SUMDW?DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVAX,0MOVBL,0E1:INCBLADDAX,BXCMPAX,500JBEE1MOV[N],BXMOV[SUM],AXE2:MOVAX,BXMOVBL,10DIVBLADDAL,30HMOVDL,ALMOVCL,AHMOVAH,2INT21HADDCL,30HMOVDL,CLMOVAH,2INT21HMOVAH,2MOVDL,0AHINT21HMOVAX,SUMCWDMOVBX,100DIVBXMOVCX,DXADDAL,30HMOVDL,ALMOVAH,2INT21HMOVBL,10MOVAX,CXDIVBLMOVCL,AHMOVAH,2ADDAL,30HMOVDL,ALINT21HMOVAH,2ADDCL,30HMOVDL,CLINT21HMOVAH,4CHINT21HCODEENDSENDSTART2.从键盘输入学生成绩(A、B、C、D),自动汇总并显示各类分数的人数。按下$键则停止输入;若按下A、B、C、D之外的键则提示“INPUTERROR”信息。DATASEGMENTM1DB'PleaseinputA,B,C,D:',13,10,'$'M2DB13,10,'Inputerror!',13,10,'$'M3DB13,10,'ThenumberofAis:$'M4DB13,10,'ThenumberofBis:$'M5DB13,10,'ThenumberofCis:$'M6DB13,10,'ThenumberofDis:$'DATAENDSSTACKSEGMENTSTACKENDSCODESEGMENTASSUMECS:CODE,DS:DATA,SS:STACKSTART:MOVAX,DATAMOVDS,AXMOVAH,9MOVDX,OFFSETM1INT21HMOVBX,0MOVCX,0E1:MOVAH,1INT21HMOVAH,41HCMPAL,AHJNZE2INCBLJMPE1E2:MOVAH,42HCMPAH,ALJNZE3INCBHJMPE1E3:MOVAH,43HCMPAH,ALJNZE4INCCLJMPE1E4:MOVAH,44HCMPAH,ALJNZE5INCCHJMPE1E5:MOVAH,24HCMPAH,ALJZE6MOVAH,9MOVDX,OFFSETM2INT21HJMPE1E6:MOVAH,9MOVDX,OFFSETM3INT21HMOVAH,2ADCBL,30HMOVDL,BLINT21HMOVAH,9MOVDX,OFFSETM4INT21HMOVAH,2ADCBH,30HMOVDL,BHINT21HMOVAH,9MOVDX,OFFSETM5INT21HMOVAH,2ADCCL,30HMOVDL,CLINT21HMOVAH,9MOVDX,OFFSETM6INT21HMOVAH,2ADCCH,30HMOVDL,CHINT21HMOVAH,4CHINT21HCODEENDSENDSTART3.动态输入20个二位无符号数,找出其中最大数并显示。DATASSEGMENTM1DB'Pleaseinput5numbers:',13,10,'$'M2DB'Thebiggestnumberis:$'M3DB'',13,10,'$'MAXDW?DATASENDSSTACKSSEGMENTSTACKSENDSCODESSEGMENTASSUMECS:CODES,DS:DATAS,SS:STACKSSTART:MOVAX,DATASMOVDS,AXMOVMAX,0LEADX,M1MOVAH,9INT21HMOVCL,5LP:MOVAH,1INT21HSUBAL,30HMOVBH,ALMOVAH,1INT21HSUBAL,30HMOVBL,ALLEADX,M3MOVAH,9INT21HCMPMAX,BXJNLEXITXCHGMAX,BXEXIT:LOOPLPLEADX,M2MOVAH,9INT21HMOVBX,MAXADDBH,30HMOVDL,BHMOVAH,2INT21HADDBL,30HMOVDL,BLMOVAH,2INT21HMOVAH,4CHINT21HCODESENDSENDSTART4.设数据区有两个字符串,串1的长度为5,串2的长度为10。编程:若串2的最后5个字符和串1相同,则置FLAG单元为“Y”,否则置为“N”。DATASSEGMENTS1DB'DKJFD$'S2DB'DSFGDDDJFD$'FLAGDB'THEFLAFISTHE:$'DATASENDSCODESSEGMENTASSUMECS:CODES,DS:DATAS,ES:DATASSTART:MOVAX,DATASMOVDS,AXMOVES,AXLEADX,FLAGMOVAH,9INT21HLEASI,S1LEADI,S2+5MOVCX,5REPECMPSBJNEEXITMOVAH,2MOVDL,'Y'INT21HJMPOVEREXIT:MOVAH,2MOVDL,'N'INT21HOVER:MOVAH,4CHINT21HCODESENDSENDSTART5.编写打印图形程序DATASSEGMENTsdb'9876543210',13,10,'$'adw?DATASENDSCODESSEGMENTASSUMECS:CODES,DS:DATASSTART:MOVAX,DATASMOVDS,AXmovcx,10movbx,9mova,2loop1:movdl,0ahmovah,2int21hmovdl,0dhmovah,2int21hloop2:movdl,s[bx]movah,2int21hincbxcmpbx,9jbeloop2subbx,aincalooploop1MOVAH,4CHINT21HCODESENDSENDSTART6.用子程序结构编写程序:从键盘入一个二位十进制数的月份(01~12),然后显示相应的英文缩写名。DATASSEGMENTPARA'DATA'THREEDB4MONINDB4,5DUP(?)ALFMONDB4,'???.','$'MONTABDB'JAN.','FEB.','MAR.','APR.','MAY.','JUN.','JUL.','AUG.','SEP.','OCT.','NOV.','DEC.'DATASENDSCODESSEGMENTPARA'CODE'ASSUMECS:CODES,DS:DATAS,ES:DATASMAINPROCFARPUSHDSSUBAX,AXPUSHAXMOVAX,DATASMOVDS,AXMOVES,AXCALLINPUTCALLLOCATECALLDISPLAYRETMAINENDPINPUTPROCNEARPUSHDXMOVAH,0AHLEADX,MONININT21HMOVAH,MONIN+2MOVAL,MONIN+3XORAX,3030HCMPAH,00JZRETURNSUBAH,AHADDAL,10RETURN:POPDXRETINPUTENDPLOCATEPROCNEARPUSHSIPUSHDIPUSHCXLEASI,MONTABDECALMULTHREEADDSI,AXMOVCX,03CLDLEADI,ALFMON+1REPMOVSBPOPCXPOPDIPOPSIRETLOCATEENDPDISPLAYPROCNEARPUSHDXLEADX,ALFMON+1MOVAH,09INT21HPOPDXRETDISPLAYENDPCODESENDSENDMAIN7.数组排序DATASSEGMENTSTRINGDB'INPUT20NUMBERS:',0AH,0DH,'$'BUFDB20DUP(?)DATASENDSCODESSEGMENTASSUMECS:CODES,DS:DATASSTART:MOVAX,DATASMOVDS,AXLEADX,STRINGMOVAH,9INT21HMOVCX,20MOVSI,0LOOP1:;动态输入20个无符号的两位数MOVAH,1INT21HSUBAL,30HMOVBL,10MULBLMOVDX,AXMOVAH,1INT21HSUBAL,30HADDDL,ALMOVBL,DLMOVAH,2MOVDL,''INT21HMOVBUF[SI],BLINCSILOOPLOOP1MOVCX,19;比较19次E1:MOVDI,CXMOVBX,0E2:;用冒泡法比较,前后比较MOVAL,BUF[BX]CMPAL,BUF[BX+1]JNGE3XCHGAL,BUF[BX+1]MOVBUF[BX],ALE3:ADDBX,1LOOPE2MOVCX,DILOOPE1MOVAH,2MOVDL,0AHINT21HMOVAH,2MOVDL,0DHINT21HMOVCL,20;从小到大输出数组MOVBX,0MOVSI,0LOOP2:MOVAL,BUF[SI]CBWMOVBL,10DIVBLMOVBH,AHMOVAH,2ADDAL,30HMOVDL,ALINT21HMOVAH,2ADDBH,30HMOVDL,BHINT21HMOVAH,2MOVDL,''INT21HINCSILOOPLOOP2MOVAH,2MOVDL,0AHINT21HMOVAH,2MOVDL,0DHINT21HMOVAH,4CHINT21HCODESENDSENDSTART8.求三个数中最大的数DATASSEGMENTBUF1DB3BUF2DB9BUF3DB7MAXDB?STRINGDB'Themaxnamberis:',13,10,'$'DATASENDSSTACKSSEGMENTSTACKSENDSCODESSEGMENTASSUMECS:CODES,DS:DATAS,SS:STACKSSTART:MOVAX,DATASMOVDS,AXMOVBL,BUF2CMPBUF1,BLJGNEXTMOVCL,BUF3CMPBUF2,CLJGE3JMPE1NEXT:MOVCL,BUF3CMPBUF1,CLJGE2JMPE1E1:MOVBL,BUF3MOVMAX,BLJMPOVERE2:MOVAL,BUF1MOVMAX,ALJMPOVERE3:MOVCL,BUF2MOVMAX,CLJMPOVEROVER:MOVDX,OFFSETSTRINGMOVAH,9INT21HMOVAH,2ADDMAX,30HMOVDL,MAXINT21HMOVAH,4CHINT21HCODESENDSENDSTART
本文标题:一些简单的汇编程序
链接地址:https://www.777doc.com/doc-5598924 .html