您好,欢迎访问三七文档
当前位置:首页 > 临时分类 > 北理工8086汇编语言上机试题及答案(二)
1.请任意输入一个字符串,将其中大写字母换成小写字母,并将结果显示在屏幕上。2.请任意输入一个字符串,将其中的英文字母全部删除,并将结果显示在屏幕上。3.现有一组字符串为data,name,time,file,code,path,user,exit,quit,text,请编写程序从键盘输入4个字符的字符串,若存在将其修改为disk,并在显示器上显示。4.现有一组字符串为ram,yes,red,the,get,for,and,key,not,may,请编写程序将他们按ASCII大小排序,并在显示器上显示。5.现有一组字符串为data,name,time,file,code,path,user,exit,quit,text,请编写程序从键盘输入4个字符的字符串,若存在将其删除,并在显示器上显示。6.现有一组字符串为data,name,time,file,code,path,user,exit,quit,text,请编写程序将上述字符串排序(升序)并插入disk使其人仍然有序,并在显示器上显示。答案部分:Answer1:DATASEGMENTBUFDB0FFHDB?DB0FFHDUP(?)STROUTDB0DH,0AH,0FDHDUP(?)DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXLEADX,BUFMOVAH,0AHINT21HLEASI,BUF[2]LEADI,STROUT[2]MOVCL,BUF[1]XORCH,CHAGAIN:CMPBYTEPTR[SI],'A'JBNOTUPCMPBYTEPTR[SI],'Z'JANOTUPMOVAL,[SI]ADDAL,20HMOV[DI],ALJMPNEXTNOTUP:MOVAL,[SI]MOV[DI],ALNEXT:INCSIINCDILOOPAGAINMOVBYTEPTR[DI],'$'LEADX,STROUTMOVAH,09HINT21HMOVAH,4CHINT21HCODEENDSENDSTARTAnswer2:DATASEGMENTBUFDB0FFHDB?DB0FFHDUP(?)STROUTDB0DH,0AH,0FDHDUP(?)DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXLEADX,BUFMOVAH,0AHINT21HLEASI,BUF[2]LEADI,STROUT[2]MOVCL,BUF[1]XORCH,CHAGAIN:CMPBYTEPTR[SI],'A'JBNOTUPCMPBYTEPTR[SI],'Z'JANOTUPINCSIJMPNEXTNOTUP:CMPBYTEPTR[SI],'a'JBNOTALPHACMPBYTEPTR[SI],'z'JANOTALPHAINCSIJMPNEXTNOTALPHA:MOVAL,[SI]MOV[DI],ALINCSIINCDINEXT:LOOPAGAINMOVBYTEPTR[DI],'$'LEADX,STROUTMOVAH,09HINT21HMOVAH,4CHINT21HCODEENDSENDSTARTAnswer3:DATASEGMENTBUFDB05HDB?DB05HDUP(?)STROUTDB0DH,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'DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATA,ES:DATASTART:MOVAX,DATAMOVDS,AXMOVES,AXLEADX,BUFMOVAH,0AHINT21HLEABX,STROUT[2]LEASI,BUF[2]LEADI,STROUT[2]MOVCX,10AGAIN:CLDPUSHCXMOVCX,4REPZCMPSBPOPCXJNZNEXTLEASI,REPLACEMOVDI,BXMOVDX,4SUBAGAIN:MOVAL,[SI]MOV[DI],ALINCSIINCDIDECDXJNZSUBAGAINJMPEXITNEXT:LEASI,BUF[2]ADDBX,6MOVDI,BXLOOPAGAINEXIT:LEADX,STROUTMOVAH,09HINT21HMOVAH,4CHINT21HCODEENDSENDSTARTAnswer4:DATASEGMENTBUFDB0DH,0AH,'ram'DB0DH,0AH,'yes'DB0DH,0AH,'red'DB0DH,0AH,'the'DB0DH,0AH,'get'DB0DH,0AH,'for'DB0DH,0AH,'and'DB0DH,0AH,'key'DB0DH,0AH,'not'DB0DH,0AH,'may','$'TMPDB'???'DATAENDSSTACKSEGMENTSTACKDB0FFHDUP(?)STACKENDSCODESEGMENTASSUMECS:CODE,DS:DATA,ES:DATAMAINPROCNEARSTART:MOVAX,DATAMOVDS,AXMOVES,AXLEABX,BUF[2]MOVDH,9AGAIN0:MOVDI,BXMOVSI,DIADDSI,5MOVDL,DHAGAIN1:PUSHSIPUSHDIMOVCX,3CLDREPZCMPSBPOPDIPOPSIJANOTABOVEMOVDI,SIJMPNEXT1NOTABOVE:NEXT1:ADDSI,5DECDLJNZAGAIN1NEXT0:CALLXCHGS3ADDBX,5DECDHJNZAGAIN0LEADX,BUFMOVAH,09HINT21HMOVAH,4CHINT21HMAINENDPXCHGS3PROCNEARPUSHSIPUSHDIPUSHCXMOVSI,DIMOVDI,BXMOVCX,3AGAINXCHGS3:MOVAL,[SI]MOVAH,[DI]MOV[SI],AHMOV[DI],ALINCSIINCDILOOPAGAINXCHGS3POPCXPOPSIPOPDIRETXCHGS3ENDPCODEENDSENDSTARTAnswer5:DATASEGMENTBUFDB05HDB?DB05HDUP(?)STROUTDB0DH,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,'test','$'DATAENDSSTACKSEGMENTSTACKDB100DUP(?)STACKENDSCODESEGMENTASSUMECS:CODE,DS:DATA,ES:DATA,SS:STACKSTART:MOVAX,DATAMOVDS,AXMOVES,AXMOVAX,STACKMOVSS,AXLEADX,BUFMOVAH,0AHINT21HLEASI,BUF[2]LEADI,STROUT[2]MOVDL,10AGAIN0:PUSHSIPUSHDIMOVCX,4CLDREPZCMPSBPOPDIPOPSIJEDELADDDI,7DECDLJNZAGAIN0JMPEXITDEL:CLDMOVAL,20HMOVCX,4REPSTOSBEXIT:LEADX,STROUTMOVCX,10AGAIN1:PUSHDXMOVBX,DXCMPBYTEPTR[BX+2],''JENEXT1MOVAH,09HINT21HNEXT1:POPDXADDDX,7LOOPAGAIN1MOVAH,4CHINT21HCODEENDSENDSTARTAnswer6:DATASEGMENTSTRINSERTDB'disk'BUFDB0DH,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,'test'DB0DH,0AH,''DB0DH,0AH,'$'DATAENDSSTACKSEGMENTSTACKDW0FFHDUP(?)STACKENDSCODESEGMENTASSUMECS:CODE,DS:DATA,ES:DATA,SS:STACKSTART:MOVAX,DATAMOVDS,AXMOVES,AXLEABX,BUF[2]MOVDL,9AGAIN0:MOVDI,BXMOVSI,DIADDSI,6MOVDH,DLAGAIN1:PUSHSIPUSHDICLDMOVCX,4REPZCMPSBPOPDIPOPSIJANEXT1MOVDI,SINEXT1:ADDSI,6DECDHJNZAGAIN1NEXT0:CALLXCHGS4ADDBX,6DECDLJNZAGAIN0LEADX,BUFMOVAH,09HINT21HLEABX,BUF[2+6*10]LEASI,STRINSERTLEADI,BUF[2]MOVDL,10AGAIN2:PUSHSIPUSHDICLDMOVCX,4REPCMPSBPOPDIPOPSIJBSHIFTRIGHTNEXT2:ADDDI,6DECDLJNZAGAIN2SHIFTRIGHT:PUSHDIMOVAX,BXSUBAX,DIADDBX,3MOVSI,BXSUBSI,6MOVDI,BXSTDMOVCX,AXREPMOVSBINSERT:POPDILEASI,STRINSERTCLDMOVCX,4REPMOVSBLEADX,BUFMOVAH,09HINT21HMOVAH,4CHINT21HXCHGS4PROCNEARPUSHSIPUSHDIPUSHCXMOVSI,BXCLDMOVCX,4AGAINXCHGS4:MOVAL,[SI]MOVAH,[DI]MOV[SI],AHMOV[DI],ALINCSIINCDILOOPAGAINXCHGS4POPCXPOPDIPOPSIRETXCHGS4ENDPCODEENDSENDSTART
本文标题:北理工8086汇编语言上机试题及答案(二)
链接地址:https://www.777doc.com/doc-4824864 .html