资源描述:
《cpu与汇编语言上机考试题》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、一、1.请任意输入一个字符串,将该串倒序后在屏幕上显示。.modelsmall.stack10h.datastringdb100dup(50)#db:definedbyte,定义100个字节,初始化为50.codestart:movax,@datamovds,ax#ds:数据段寄存器,对应全局变量leadx,string#lea:存储器地址偏移量存入dxmovah,0ah#0ah:中断号,从键盘接收字符串并放入缓冲区(回车键结束)。缓冲区首地址存于dx。缓冲区第2字节开始实际存字符。int21h#转入中断子程序的入口movdl,0ah#0ah:换行符的asc码movah,02
2、h#02h:显示输出int21hxorbh,bhmovbl,string[1]#缓冲区的第0字节存入最多接收的字符数,第1字节存放实际输入的字数lop:movdl,string[bx+1]movah,02hint21hdecbxjnzlopmovah,4ch#4ch:退出程序int21hendstart2.请任意输入一个字符串,统计其中空格和A的个数,并将结果显示在屏幕上。.modelsmall.stack10h.databufdb100dup(50)#定义100字节初始化50count1db00h#初始化0space个数count2db00h#A个数str1db'numof
3、spaceis:$'str2db'numofAis:$'.codestart:movax,@datamovds,axleadx,bufmovah,0ahint21hmovdl,0ah#换行movah,02h#显示输出int21hxorbh,bh#0movbl,buf[1]lop:moval,buf[bx+1]#最后一个字符xoral,''#space?jzspacemoval,buf[bx+1]xoral,'A'jzchar_Anext:decbxjnzlopjzshowspace:addcount1,01hjmpnextchar_A:addcount2,01hjmpnext
4、show:leadx,str1movah,09h#显示字符串int21hmovdl,count1adddl,30hmovah,02hint21hmovdl,0ah#换行movah,02h#输出int21hleadx,str2movah,09hint21hmovdl,count2adddl,30hmovah,02hint21hmovdl,0ahmovah,02hint21hmovah,4chint21hendstart1.请任意输入一个字符串,将其中的空格全部删除,并将结果显示在屏幕上。.modelsmall.stack10h.databufdb100dup(50).codes
5、tart:movax,@datamovds,axleadx,bufmovah,0ahint21hmovdl,0ahmovah,02hint21hxorbh,bhmovbl,buf[1]movsi,0002hlop:moval,buf[si]xoral,''jznextjnzshownext:decbxjzbreakincsijmplopshow:movdl,buf[si]movah,02hint21hjmpnextbreak:movah,4chint21hendstart1.请任意输入一个字符串,将其中A换成CC,并将结果显示在屏幕上。.modelsmall.stack10h
6、.databufdb100dup(50).codestart:movax,@datamovds,axleadx,bufmovah,0ahint21hmovdl,0ahmovah,02hint21hxorbh,bhmovbl,buf[1]movsi,0002hlop:moval,buf[si]xoral,'A'jzshow_ccjnzshow_charnext:decbxjzbreakincsijmplopshow_cc:movdl,'C'movah,02hint21hint21hjmpnextshow_char:movdl,buf[si]movah,02hint21hjmpn
7、extbreak:movah,4chint21hendstart1.请任意输入一个字符串,将其中大写字母换成小写字母,并将结果显示在屏幕上。.modelsmall.stack10h.databufdb100dup(50).codestart:movax,@datamovds,axleadx,bufmovah,0ahint21hmovdl,0ahmovah,02hint21hxorbh,bhmovbl,buf[1]leasi,buf+2;cld;将标志寄存器的方向标志位df清零lop:lodsb;将子串中