资源描述:
《川农汇编语言实验五(1)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、实验五分支结构程序设计信息与工程技术学院10级电气2班吕峰201051565.9stackssegmentstacksdb20dup(0)stacksendsdatasegmentnequ4chardbn+1;输入内存字符db0dbn+1dup(0)inputdb'Inputthenumber:',0dh,0ah,'$'enterdb0dh,0ah,'$'outputdb'Resultis:',0dh,0ah,'$'dataendscodesegmentassumecs:code,ss:stacks,ds:datastart:movax,datamovds,axleadx,i
2、nputmovah,9int21hleadx,charmovah,0ahint21hleadx,entermovah,9int21hmovsi,2movcx,4l0:movbl,char[si]cmpbl,30hjbstartcmpbl,39hjbel00cmpbl,61hjbstartcmpbl,66hjastartsubbl,57hjmpl333l00:subbl,30hl333:movchar[si],blincsideccxjnzl0leadx,outputmovah,9int21hmovsi,2l000:movbl,char[si]movch,4movcl,4shl
3、bl,clll00:testbl,80hjnzl1movdl,'0'movah,2int21hjmpl2l1:movdl,'1'movah,2int21hl2:shlbl,1decchjnzll00incsicmpsi,6jnel000movah,4chint21hcodeendsendstart5.21DSEGSEGMENTARRAYDW3DUP(?)DSEGENDS;--------------------------------------------------------------------------CSEGSEGMENTMAINPROCFARASSUMECS
4、:CSEG,DS:DSEGSTART:PUSHDS;设置返回DOSSUBAX,AXPUSHAXMOVAX,DSEGMOVDS,AX;给DS赋值BEGIN:LEASI,ARRAYMOVDX,0;(DX)用于存放所求的结果MOVAX,[SI]MOVBX,[SI+2]CMPAX,BX;比较第一和第二两个数是否相等JNENEXT1INCDXNEXT1:CMP[SI+4],AX;比较第一和第三两个数是否相等JNENEXT2INCDXNEXT2:CMP[SI+4],BX;比较第二和第三两个数是否相等JNENUMINCDXNUM:CMPDX,3JLDISPDECDXDISP:ADDDL,3
5、0H;转换为ASCII码MOVAH,2;显示一个字符INT21HRETMAINENDPCSEGENDS;以上定义代码段;--------------------------------------------------------------------------ENDSTART第三题:DSEGSEGMENTDATAXDB6HDATAYDB4HDSEGENDSCSEGSEGMENTASSUMECS:CSEG,DS:DSEGSTART:MOVAX,DSEGMOVDS,AXMOVBL,DATAXMOVBH,DATAYMOVAH,01HINT21HCMPAL,'+'JEQ1CM
6、PAL,'-'JEQ2CMPAL,'*'JEQ3CMPAL,'/'JEQ4Q4:MOVAL,BLSUBAH,AHDIVBHMOVBL,ALJMPQ5Q3:MOVAL,BHMULBLMOVBL,ALJMPQ5Q2:SUBBL,BHJMPQ5Q1:ADDBL,BHQ5:MOVAL,BLMOVCL,4SHRAL,CLADDAL,30HCMPAL,39HJBEOK1ADDAL,07HOK1:MOVDL,ALMOVAH,02HINT21HMOVAL,BLANDAL,0FHADDAL,30HCMPAL,39HJBEOK2ADDAL,07HOK2:MOVDL,ALMOVAH,02HINT2
7、1HMOVAH,4CHINT21HCSEGENDSENDSTART第四题:ASSUMECS:CODE,DS:DATA,SS:STACKDATASEGMENTNUMBERDB0STR1DB'Pleaseenteranumber:$'DATAENDSSTACKSEGMENTSTACKDB80DUP(0)STACKENDSCODESEGMENTSTART:MOVAX,DATAMOVDS,AXMOVAX,STACKMOVSS,AXMOVDX,OFFSETSTR1MOVAH,09HINT21HMOVAH,01HI