试一下要多久,现在开始,阿门。。。emu8086编译测试通过,附运行测试截图====================================;multi-segmentexecutablefiletemplate.datasegment;addyourdatahere!oper1dw0000h;oper2sumdb5dup(00h)altempdb00hmessage1db\'Thefirstnumber:\',\'$\'message2db\'Thesec0ndnumber:\',\'$\'message3db\'Thesumofthemis:\',\'$\'message4db0dh,0ah,\'Theinputnumberbeginswith-orandendwithenterorfourbits\',\'$\'message5db\'PressESCtoexitoranyotherkeytocontiune\',\'$\'endsstacksegmentdw128dup(0)endscodesegmentstart:;setsegmentregisters:movax,datamovds,axmoves,ax;addyourcodehere;inputoper1:callnewlinebeginleadx,message1movah,09hint21h;outputstringatds:dxcallreadsign;thesignwouldbeindl(zerolabel\'-\';nzerolabel\'\')callreadabsval;theasbvalwouldbeinbxcmpdl,00hjznegative1movoper1,bxjmpinputoper2negative1:xorax,axsubax,bxmovoper1,axinputoper2:callnewlinebeginleadx,message2movah,09hint21h;outputstringatds:dxcallreadsign;thesignwouldbeindl(zerolabel\'-\';nzerolabel\'\')callreadabsval;theasbvalwouldbeinbxcmpdl,00hjznegative2movax,bxjmpout_resultnegative2:xorax,axsubax,bxout_result:pushaxcallnewlinebeginleadx,message3movah,09hint21h;outputstringatds:dxpopax;ax=oper2movbx,oper1;bx=oper1addax,bx;ax=sumofoper1andoper2calloutresult;callnewlinebeginleadx,message5movah,09hint21h;outputstringatds:dxmovah,08hint21hcmpal,1bhjzexitcallnewlinebeginleadx,message4movah,09hint21h;outputstringatds:dxjmpstartexit:movax,4c00h;exittooperatingsystem.int21h;---------------------------------------;callreadabsvalreadabsvalprocnear;in:none;out:bx=theoperatorpushaxpushcxpushdxxorbx,bxmovcx,04hmax4bcd:callreadchar_numorentercmpal,0dhjzreadabsvaloutmovaltemp,almovax,bxmovbx,0ahmulbxmovbx,axmoval,altempxorah,ahaddbx,axloopmax4bcdreadabsvalout:popdxpopcxpopaxretreadabsvalendp;---------------------------------------;callreadchar_numorenterreadchar_numorenterprocnear;in:none;out:al=thenumvalorenterpushdxreadchar_numorenterredo:movah,08hint21hcmpal,0dhjzreadchar_numorenteroutcmpal,30hjlreadchar_numorenterredocmpal,39hjgreadchar_numorenterredomovah,02hmovdl,alint21hsubax,0230hreadchar_numorenterout:popdxretreadchar_numorenterendp;---------------------------------------;callreadsignreadsignprocnear;in:none;out:dl=zero-ornzeropushaxrereadsign:movah,08hint21hcmpal,2bhjzoppsigncmpal,2dhjznegsignjmprereadsignnegsign:movdl,2dhmovah,02hint21hxordl,dlpopaxretoppsign:movdl,2bhmovah,02hint21hmovdl,01hpopaxretreadsignendp;---------------------------------------;calloutresult;outresultprocnearmovbx,axjsoutnegtivemovdl,2bhjmpoutresultvaloutnegtive:movdl,2dhnegbxoutresultval:;outsignmovah,02hint21h;outabsvalleadi,sumadddi,04hmovax,bxmovbx,0ahmovcx,05hsent:xordx,dxdivbxadddl,30hmov[di],dldecdiloopsentleasi,summovbl,00h;asaflatofheadzeromovah,02hmovcx,05hout_Dnum:movdl,[si]cmpdl,30hjnzoutnumtestbl,01hjnzoutnumcmpcx,01hjzoutnumjmpoutvalcontinueoutnum:movbl,01hint21houtvalcontinue:incsiloopout_Dnumretoutresultendp;---------------------------------------;callnewlinebeginnewlinebeginprocnearpushaxpushdxmovah,02hmovdl,0dhint21hmovdl,0ahint21hpopdxpopaxretnewlinebeginendpendsendstart;setentrypointandstoptheassembler.====================================masm5.0测试通过版本datasegmentoper1dw0000hsumdb5dup(00h)altempdb00hmessage1db\'Thefirstnumber:\',\'$\'message2db\'Thesec0ndnumber:\',\'$\'message3db\'Thesumofthemis:\',\'$\'message4db0dh,0ah,\'Theinputnumberbeginswith-orandendwithenterorfourbits\',\'$\'message5db\'PressESCtoexitoranyotherkeytocontiune\',\'$\'dataendsstacksegmentdw128dup(0)stackendscodesegmentassumecs:code,ds:data,ss:stack,es:datastart:movax,datamovds,axmoves,axcallnewlinebeginleadx,message1movah,09hint21hcallreadsigncallreadabsvalcmpdl,00hjznegative1movoper1,bxjmpinputoper2negative1:xorax,axsubax,bxmovoper1,axinputoper2:callnewlinebeginleadx,message2movah,09hint21hcallreadsigncallreadabsvalcmpdl,00hjznegative2movax,bxjmpout_resultnegative2:xorax,axsubax,bxout_result:pushaxcallnewlinebeginleadx,message3movah,09hint21h;outputstringatds:dxpopax;ax=oper2movbx,oper1;bx=oper1addax,bx;ax=sumofoper1andoper2calloutresult;callnewlinebeginleadx,message5movah,09hint21h;outputstringatds:dxmovah,08hint21hcmpal,1bhjzexitcallnewlinebeginleadx,message4movah,09hint21h;outputstringatds:dxjmpstartexit:movax,4c00h;exittooperatingsystem.int21h;---------------------------------------;callreadabsvalreadabsvalprocnear;in:none;out:bx=theoperatorpushaxpushcxpushdxxorbx,bxmovcx,04hmax4bcd:callreadchar_numorentercmpal,0dhjzreadabsvaloutmovaltemp,almovax,bxmovbx,0ahmulbxmovbx,axmoval,altempxorah,ahaddbx,axloopmax4bcdreadabsvalout:popdxpopcxpopaxretreadabsvalendp;---------------------------------------;callreadchar_numorenterreadchar_numorenterprocnear;in:none;out:al=thenumvalorenterpushdxreadchar_numorenterredo:movah,08hint21hcmpal,0dhjzreadchar_numorenteroutcmpal,30hjlreadchar_numorenterredocmpal,39hjgreadchar_numorenterredomovah,02hmovdl,alint21hsubax,0230hreadchar_numorenterout:popdxretreadchar_numorenterendp;---------------------------------------;callreadsignreadsignprocnear;in:none;out:dl=zero-ornzeropushaxrereadsign:movah,08hint21hcmpal,2bhjzoppsigncmpal,2dhjznegsignjmprereadsignnegsign:movdl,2dhmovah,02hint21hxordl,dlpopaxretoppsign:movdl,2bhmovah,02hint21hmovdl,01hpopaxretreadsignendp;---------------------------------------;calloutresult;outresultprocnearmovbx,axjsoutnegtivemovdl,2bhjmpoutresultvaloutnegtive:movdl,2dhnegbxoutresultval:;outsignmovah,02hint21h;outabsvalleadi,sumadddi,04hmovax,bxmovbx,0ahmovcx,05hsent:xordx,dxdivbxadddl,30hmov[di],dldecdiloopsentleasi,summovbl,00h;asaflatofheadzeromovah,02hmovcx,05hout_Dnum:movdl,[si]cmpdl,30hjnzoutnumtestbl,01hjnzoutnumcmpcx,01hjzoutnumjmpoutvalcontinueoutnum:movbl,01hint21houtvalcontinue:incsiloopout_Dnumretoutresultendp;---------------------------------------;callnewlinebeginnewlinebeginprocnearpushaxpushdxmovah,02hmovdl,0dhint21hmovdl,0ahint21hpopdxpopaxretnewlinebeginendpcodeendsendstart;setentrypointandstoptheassembler.=======================================测试运行截图:
|