汇编语言进制转换器

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

这是一个用汇编语言编写的视线二、十、十六进制之间相互转换的程序代码。datasegment;*****主程序中的提示信息*****str1DB0AH,0DH,'********************************************$'str2DB0AH,0DH,'****$'str3DB0AH,0DH,'*ca*welcomeyou!**$'str4DB0AH,0DH,'****$'str5DB0AH,0DH,'**thisisprogrammeofshuzhizhuanghuan**$'str6db0AH,0DH,'****$'str7db0AH,0DH,'**pressbtobeginexchange!**$'str8DB0AH,0DH,'**pressqtoexit!**$'str9DB0AH,0DH,'****$'str10DB0AH,0DH,'********************************************$'str11db0ah,0dh,'inputerror,pleaserepess!','$'ALTERdb0ah,0dhdb0ah,0dhdb'Pleasealteryouroption',0AH,0DHdb'1:Decimalnumberchangeintobinarynumber',0AH,0DH;十进制转化为二进制db'2:Binarynumberchangeintodecimalnumber',0AH,0DH;二进制转化为十进制db'3:Decimalnumberchangeintohexadecimalnumber',0AH,0DH;十进制转化为十六进制db'4:Hexadecimalnumberchangeintodecimalnumber',0AH,0DH;十六进制转化为十进db'5:Binarynumberchangeintohexadecimalnumber',0AH,0DH;二进制转化为十六进制db'6:Hexadecimalnumberchangeintobinarynumber',0AH,0DH;十六进制转化为二进制db'7:EXIT',0AH,0DH,'$'SHIdb'Pleaseinputadecimalnumber',0AH,0DH,'$';输入十进制数ERdb'PleaseinputaBinarynumber',0AH,0DH,'$';输入二进制数SLIUdb'PleaseinputaHexadecimalnumber',0AH,0DH,'$';输入十六进制数WROdb'Youhaveinputawrongnumber,pleaseinputagain!',0AH,0DH,'$'RESdb'Theresultis:',0AH,0DH,'$'dataendscodesegmentassumecs:code,ds:datastart:movax,datamovds,axmovdl,0AHmovah,2int21hdispmacromleadx,mmovah,9int21hendmdispstr1dispstr3dispstr4dispstr5dispstr6dispstr7dispstr8dispstr9dispstr10lop:movah,8int21hcmpal,'b'jzltolcmpal,'q'jzEXITdispstr11jmplopltol:leadx,ALTER;显示输入选择movah,9int21hmovah,1;输入选择int21hcmpal,'1';如果是第一项跳转到子程序OnechangejzLAB1cmpal,'2';如果是第二项跳转到子程序TwochangejzLAB2cmpal,'3';如果是第三项跳转到子程序TherechangejzLAB3cmpal,'4';如果是第四项跳转到子程序FourchangejzLAB4cmpal,'5'jzLAB5;如果是第五项跳转到子程序Fivechangecmpal,'6'jzLAB6;如果是第五项跳转到子程序Fivechangecmpal,'7';如果是第七项跳转到子程序EXITjzaltcallWRONG;jmpSTARTalt:leadx,str1jmpstartLAB1:callOnechange;跳转到子程序OnechangejmpltolLAB2:callTwochange;跳转到子程序TwochangejmpltolLAB3:callThreechange;跳转到子程序ThreechangejmpltolLAB4:callFourchange;跳转到子程序FourchangejmpltolLAB5:callFivechange;跳转到子程序FivechangejmpltolLAB6:callSixchange;跳转到子程序FivechangejmpltolEXIT:movah,4ch;退出DOS界面int21h;子程序Onechange;功能:把十进制转化为二进制数Onechangeprocnearmovdl,0AHmovah,2int21hleadx,SHI;显示输入十进制数movah,9int21hMOVBX,0MOVSI,16newchar7:MOVAH,1INT21hSUBAL,30hJLshow1CMPAL,9dJGshow1CBWXCHGAX,BXMOVCX,10dMULCXXCHGAX,BXADDBX,AXJMPnewchar7show1:movdl,0AHmovah,2int21hLEADX,RESMOVAH,9INT21hshow7:ROLBX,1MOVAL,BLANDAL,1hADDAL,30hMOVDL,ALMOVAH,2INT21hDECSIJNZshow7RETOnechangeENDP;子程序Twochange;功能:把二进制转化为十进制数Twochangeprocnearmovdl,0AHmovah,2int21hleadx,ER;显示输入二进制数movah,9int21hMOVBX,0MOVSI,16newchar2:MOVAH,1INT21hSUBAL,30hJLshow3CMPAL,10dJLadd_to4JMPshow3add_to4:MOVCL,1SHLBX,CLMOVAH,0ADDBX,AXJMPnewchar2show3:movdl,0AHmovah,2int21hLEADX,RES;显示输出结果MOVAH,9INT21hMOVCX,10000dCALLdec_div4MOVCX,1000CALLdec_div4MOVCX,100CALLdec_div4MOVCX,10CALLdec_div4MOVCX,1CALLdec_div4RETdec_div4PROCNEARMOVAX,BXMOVDX,0DIVCXMOVBX,DXMOVDL,ALADDDL,30hMOVAH,2INT21hRETdec_div4ENDPTwochangeENDP;子程序Threechange;功能:把十进制转化为十六进制ThreechangePROCNEARMOVBX,0movdl,0AHmovah,2int21hLEADX,SHIMOVAH,9INT21hMOVSI,4newchar6:MOVAH,1INT21hSUBAL,30hJLnext6CMPAL,9dJGnext6CBWXCHGAX,BXMOVCX,10dMULCXXCHGAX,BXADDBX,AXJMPnewchar6next6:movdl,0AHmovah,2int21hMOVSI,4LEADX,RES;显示输出结果MOVAH,9INT21hrotate6:MOVCL,4ROLBX,CLMOVAL,BLANDAL,0fhADDAL,30hCMPAL,3ahJLprint6ADDAL,7hprint6:MOVDL,ALMOVAH,2INT21hDECSIJNZrotate6RETThreechangeENDPFourchangePROCNEARmovdl,0AHmovah,2int21hLEADX,SLIUMOVAH,9INT21hMOVBX,0newchar5:MOVAH,1INT21hSUBAL,30hJLnext5CMPAL,10dJLadd_to5SUBAL,27hCMPAL,0ahJLnext5CMPAL,10hJGEnext5add_to5:MOVCL,4SHLBX,CLMOVAH,0ADDBX,AXJMPnewchar5next5:movdl,0AHmovah,2int21hLEADX,RES;显示输出结果MOVAH,9INT21hMOVCX,10000dCALLdec_div5MOVCX,1000dCALLdec_div5MOVCX,100dCALLdec_div5MOVCX,10dCALLdec_div5MOVCX,1dCALLdec_div5RETFourchangeENDPdec_div5PROCNEARMOVAX,BXMOVDX,0DIVCXMOVBX,DXMOVDL,ALADDDL,30hMOVAH,2INT21hRETdec_div5ENDP;子程序名:Fivechange;子程序功能:二进制转化为十六进制Fivechangeprocnearmovdl,0AHmovah,2int21hleadx,ER;显示输入二进制数movah,9int21hXORAX,AXMOVBX,AXMOVSI,4newchar1:MOVAH,1INT21hSUBAL,30hJLrotate1CMPAL,10dJLadd_to1JMProtate1add_to1:MOVCL,1SHLBX,CLMOVAH,0ADDBX,AXJMPnewchar1rotate1:movdl,0AHmovah,2int21hLEADX,RES;显示输出结果MOVAH,9INT21hrotate1_1:MOVCL,4ROLBX,CLMOVAL,BLANDAL,0fhADDAL,30hCMPAL,3ahJLprint1ADDAL,7hprint1:MOVDL,ALMOVAH,2INT21hDECSIJNZrotate1_1RETFivechangeENDP;子程序名:Sixchange;子程序功能:十六进制转化为二进制SixchangePROCNEARmovdl,0AHmovah,2int21hMOVBX,0LEADX,SLIUMOVAH,9INT21hMOVSI,16newchar8:MOVAH,1INT21hSUBAL,30hJLprint3CMPAL,10dJLadd_to2SUBAL,27hCMPAL,0ahJLprint3CMPAL,10hJGEprint3add_to2:MOVCL,4SHLBX,CLMOVAH,0ADDBX,AXJMPnewchar8print3:movdl,0AHmovah,2int21hLEADX,RESMOVAH,9INT21hprint2:ROLBX,1MOVAL,BLANDAL,1hADDAL,30hMOVDL,ALMOVAH,2INT21hDECSIJNZprint2RETSixchangeENDPWRONGprocnearmovdl,0AHmovah,2int21hleadx,WROmovah,9int21hretWRONGendpcodeendsendstart

1 / 14
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功