北京理工大学汇编上机试题和代码(修改版)1.请任意输入一个字符串,将该串倒序后在屏幕上显示。DATASSEGMENTBUF1DB0FFHDB?DB0FFHDUP(?)BUF2DB0DH,0AH,0FDHDUP(?)DATASENDSCODESSEGMENTASSUMECS:CODES,DS:DATASSTART:MOVAX,DATASMOVDS,AXLEADX,BUF1MOVAH,0AHINT21HMOVAX,0MOVAL,BUF1[1]LEASI,BUF1[1]ADDSI,AXLEADI,BUF2[2]MOVCX,0MOVCL,BUF1[1]L:MOVAL,[SI]MOV[DI],ALDECSIINCDILOOPLMOVBYTEPTR[DI],'$'LEADX,BUF2MOVAH,09HINT21HMOVAH,4CHINT21HCODESENDSENDSTART取巧:DATASEGMENTDB512DUP('$');定义可输入的字符个数BUFDB'$'DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVBX,OFFSETBUF;指针指向待显示字符串尾部AGAIN:MOVAH,01;输入字符INT21HCMPAL,0DH;是回车吗JEDISP;是,转显示DECBX;指针减1MOV[BX],AL;存入输入的字符JMPAGAIN;继续输入DISP:MOVDX,BX;定位待显示字符串首地址MOVAH,09INT21H;显示MOVAH,4CH;DOS返回INT21HCODEENDSENDSTART2.请任意输入一个字符串,统计其中空格和A的个数,并将结果显示在屏幕上。DATASEGMENTBUFDB0FFHDB?DB0FFHDUP(?)OUTPUTDB0DH,0AH,'A=000'DB0DH,0AH,'SPACE=000','$'DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXLEADX,BUFMOVAH,0AHINT21HLEASI,BUF[2]MOVCX,0MOVCL,BUF[1]L:CMPBYTEPTR[SI],'A'JNENOTACMPOUTPUT[10],'9'JECAR1INCOUTPUT[10]JMPNEXTCAR1:CMPOUTPUT[9],'9'JECAR2MOVOUTPUT[10],'0'INCOUTPUT[9]JMPNEXTCAR2:MOVOUTPUT[10],'0'MOVOUTPUT[9],'0'INCOUTPUT[8]JMPNEXTNOTA:CMPBYTEPTR[SI],''JNENEXTCMPOUTPUT[21],'9'JECSR1INCOUTPUT[21]JMPNEXTCSR1:CMPOUTPUT[20],'9'JECSR2MOVOUTPUT[21],'0'INCOUTPUT[20]JMPNEXTCSR2:MOVOUTPUT[21],'0'MOVOUTPUT[20],'0'INCOUTPUT[19]JMPNEXTNEXT:INCSILOOPLLEADX,OUTPUTMOVAH,09HINT21HMOVAX,4C00HINT21HCODEENDSEND3.请任意输入一个字符串,将其中的空格全部删除,并将结果显示在屏幕上。DATASEGMENTBUF1DB0FFHDB?DB0FFHDUP('?')BUF2DB0DH,0AH,0FDHDUP('?')DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXLEADX,BUF1MOVAH,0AHINT21HMOVCX,0MOVCL,BUF1[1]LEASI,BUF1[2]LEADI,BUF2[2]L:CMPBYTEPTR[SI],''JEMMOVAL,[SI]MOV[DI],ALINCDIM:INCSILOOPLMOVBYTEPTR[DI],'$'LEADX,BUF2MOVAH,09HINT21HMOVAX,4C00HINT21HCODEENDSEND4.请任意输入一个字符串,将其中A换成B,并将结果显示在屏幕上。DATASEGMENTBUFDB0FFHDB?DB0FFHDUP('?')DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXLEADX,BUFMOVAH,0AHINT21HMOVCX,0MOVCL,BUF[1]LEASI,BUF[2]L:CMPBYTEPTR[SI],'A'JNEMMOVBYTEPTR[SI],'B'M:INCSILOOPLMOVWORDPTR[SI],0D0AHMOVBYTEPTR[SI+2],'$'LEADX,BUF[2]MOVAH,09HINT21HMOVAX,4C00HINT21HCODEENDSEND5.请任意输入一个字符串,将其中A换成CC,并将结果显示在屏幕上。DATASEGMENTBUF1DB0FFHDB?DB0FFHDUP('?')BUF2DB0DH,0AH,0FDHDUP('?')DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXLEADX,BUF1MOVAH,0AHINT21HMOVCX,0MOVCL,BUF1[1]LEASI,BUF1[2]LEADI,BUF2[2]L:CMPBYTEPTR[SI],'A'JNEMMOVWORDPTR[DI],'CC'ADDDI,2INCSIJMPNM:MOVAL,[SI]MOV[DI],ALINCDIINCSIN:LOOPLMOVBYTEPTR[DI],'$'LEADX,BUF2MOVAH,09HINT21HMOVAX,4C00HINT21HCODEENDSEND6.请任意输入一个字符串,将其中大写字母换成小写字母,并将结果显示在屏幕上。DATASEGMENTBUF1DB0FFHDB?DB0FFHDUP('?')BUF2DB0DH,0AH,0FDHDUP('?')DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXLEADX,BUF1MOVAH,0AHINT21HMOVCX,0MOVCL,BUF1[1]LEASI,BUF1[2]LEADI,BUF2[2]L:MOVAL,[SI]MOV[DI],ALCMPBYTEPTR[DI],'a'JNBMORBYTEPTR[DI],00100000BM:INCDIINCSIN:LOOPLMOVBYTEPTR[DI],'$'LEADX,BUF2MOVAH,09HINT21HMOVAX,4C00HINT21HCODEENDSEND7.请任意输入一个字符串,将其中的英文字母全部删除,并将结果显示在屏幕上。DATASEGMENTBUF1DB0FFHDB?DB0FFHDUP('?')BUF2DB0DH,0AH,0FDHDUP('?')DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXLEADX,BUF1MOVAH,0AHINT21HMOVCX,0MOVCL,BUF1[1]LEASI,BUF1[2]LEADI,BUF2[2]L:CMPBYTEPTR[SI],'A'JNBMMOVAL,[SI]MOV[DI],ALINCSIINCDIJMPNEXTM:CMPBYTEPTR[SI],'z'JNANMOVAL,[SI]MOV[DI],ALINCSIINCDIJMPNEXTN:CMPBYTEPTR[SI],'a'JBHINCSIJMPNEXTH:CMPBYTEPTR[SI],'Z'JAOINCSIJMPNEXTO:MOVAL,[SI]MOV[DI],ALINCSIINCDIJMPNEXTNEXT:LOOPLMOVBYTEPTR[DI],'$'LEADX,BUF2MOVAH,09HINT21HMOVAX,4C00HINT21HCODEENDSEND8.现有一组字符串为data,name,time,file,code,path,user,exit,quit,text,请编写程序从键盘输入4个字符的字符串,若存在将其修改为disk,并在显示器上显示。DATASSEGMENTBUFDB05HDB?DB05HDUP('?')LIBDB0DH,0AH,'data'DB0DH,0AH,'name'DB0DH,0AH,'time'DB0DH,0AH,'file'DB0DH,0AH,'code'DB0DH,0AH,'path'DB0DH,0AH,'user'DB0DH,0AH,'exit'DB0DH,0AH,'quit'DB0DH,0AH,'text','$'REPLACEDB'disk'DATASENDSCODESSEGMENTASSUMECS:CODES,DS:DATAS,ES:DATASSTART:MOVAX,DATASMOVDS,AXMOVES,AXLEADX,BUFMOVAH,0AHINT21HLEASI,BUF[2]LEADI,LIB[2]MOVBX,DIMOVCX,10L:CLDPUSHCXMOVCX,4REPZCMPSBJNZNPOPCXMOVSI,BXLEADI,REPLACEMOVCX,4M:MOVAL,[DI]MOV[SI],ALINCDIINCSILOOPMJMPEXITN:ADDBX,6MOVDI,BXLEASI,BUF[2]LOOPLEXIT:LEADX,LIBMOVAH,09HINT21HMOVAH,4CHINT21HCODESENDSENDSTART9.现有一组字符串为ram,yes,red,the,get,for,and,key,not,may,请编写程序将他们按ASCII大小排序,并在显示器上显示。DATASEGMENTLIBDB'ram',0DH,0AHDB'yes',0DH,0AHDB'red',0DH,0AHDB'the',0DH,0AHDB'get',0DH,0AHDB'for',0DH,0AHDB'and',0DH,0AHDB'key',0DH,0AHDB'not',0DH,0AHDB'may',0DH,0AH,'$'DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATA,ES:DATASTART:MOVAX,DATAMOVDS,AXMOVDI,9A:MOVCX,DILEASI,LIBB:MOVAL,[SI]CMPAL,[SI+5]PUSHSIJAHJEOJBRO:INCSIMOVAL,[SI]CMPAL,[SI+5]JAHJBRJEOH:POPSIPUSHSIMOVBX,3M:MOVAL,BYTEPTR[SI]MOVAH,BYTEPTR[SI+5]MOVBYTEPTR[SI],AHMOVBYTEPTR[SI+5],ALINCSIDECBXJNZMR:POPSIADDSI,5LOOPBDECDIJNZALEADX,LIBMOVAH,09HINT21HMOVAH,4CHINT21HCODEENDSENDSTART10.现有一组字符串为data,name,time,file,code,path,user,exit,quit,text,请编写程序从键盘输入4个字符的字符串,若存在将其删除,并在显示器上显示。DATASEGMENTBUFDB05HDB?DB05HDUP(?)LIBDB0DH,0AH,'data','$'DB0DH,0AH,'name','$'DB0DH,0AH,'time','$'DB0DH,0AH,'file','$'DB0DH,0AH,'code','$'DB0DH,0AH,'path','$'DB0DH,0AH,'user','$'DB0DH,0AH