您好,欢迎访问三七文档
当前位置:首页 > 幼儿/小学教育 > 小学教育 > 汇编语言编写的四则运算计算机
;½öÖ§³Ö¼Ó¼õ³Ë³ýËÄÔòÔËË㣬²»Ö§³ÖÀ¨ºÅÊäÈë,Èç(3+2)*5£¬Ôò´íÎó;²»Ö§³Ö2λÊýÊäÈ룬Èç²»ÄÜÊäÈë3+13*2;Ö»Ö§³ÖһλÊýÊäÈ룬Èç3+4*5-8/4;×îÖÕµÄÔËËã½á¹û²»ÄÜ´óÓÚ127£¬Èç8*8*8£¬Ôò´íÎó;²»ÄÜʶ±ðÊäÈë±í´ïʽÊÇ·ñÕýÈ·£¬ÒªÇóʹÓÃÕß¹ý³ÌÖÐÈ·¶¨ÊäÈë±í´ïʽµÄÕýÈ·ÐÔ;¸ü¼ÓÇ¿´ó¹¦ÄܵȴýºóÐø¿ª·¢DATASEGMENTINFODB'PLEASEINPUTEXPRESSION:','$'INPUTPDB20DB?INPUTDB20DUP(?);´æ·ÅÊäÈë×Ö·û´®¼°Ò»´Î´¦ÀíºóµÄ×Ö·û´®BUFFDB20DUP(?);´æ·Å¶þ´Î´¦Àí¹ýµÄ×Ö·û´®3+5*7RESULTDB?PRINTDB0DH,0AH,'RESULTIS:'OCTRESULTDB4DUP('$');´æ·Å×îÖÕ½á¹ûNUMSTACKDB10DUP(?);²Ù×÷ÊýÕ»OPSTACKNDB0DB20DUP(?);ÔËËã·ûÕ»OPSTACKDB20DUP(?);=================10DATAENDSSTACSEGMENTSTACK;²Ù×÷ÊýÕ»DW100DUP(?)STACENDSCODESEGMENTASSUMECS:CODE,DS:DATA,SS:STACSTART:MOVAX,DATA;³õʼ»¯Êý¾Ý¶ÎºÍ¶ÑÕ»¶ÎMOVDS,AXMOVAX,STAC;========20MOVSS,AXMOVDX,OFFSETINFO;ÏÔʾÊäÈëÌáʾMOVAH,9INT21HCALLINPUTEXPCALLSIMPROC;µ÷Óüòµ¥´¦Àí±í´ïʽ¹ý³ÌMOVSI,0MOVDI,1;======30MOVBP,0AGAIN:MOVAL,INPUTP[1]MOVAH,0CMPSI,AXJADONECALLFISRTCALCJMPAGAINDONE:CALLRESULTPROCALLPRINTRESMOVAH,4CHINT21H;=======40;====================ÊäÈë±í´ïʽ================INPUTEXPPROCMOVDX,OFFSETINPUTPMOVAH,0AHINT21HRETINPUTEXPENDP;===================´¦Àí½á¹û================RESULTPROPROCMOVAL,RESULTMOVAH,0MOVBL,100MOVSI,0DIVBLADDAL,30HMOVOCTRESULT[SI],ALINCSIMOVAL,AHMOVAH,0MOVBL,10DIVBLADDAL,30HMOVOCTRESULT[SI],ALINCSIADDAH,30HMOVOCTRESULT[SI],AHRETRESULTPROENDP;================Êä³ö½á¹û===================PRINTRESPROCMOVDX,OFFSETPRINTMOVAH,9INT21HRETPRINTRESENDP;===================´¦Àí±í´ïʽ============50SIMPROCPROCMOVDI,0MOVCL,INPUTP[1]MOVCH,0SIM1:MOVAL,INPUT[DI]CMPAL,30HJBOPSUBAL,30HMOVINPUT[DI],ALOP:;=====60INCDILOOPSIM1RETSIMPROCENDP;==============½øÒ»²½´¦Àí±í´ïʽ²¢´æ·Åµ½BUFFÖÐ==========;==================×Ö·û´®ÒÀ´Î½øÕ»====================FISRTCALCPROC;======70MOVAL,INPUT[SI]CMPAL,10;ÅжÏALÊÇÊý×Ö»¹ÊÇÔËËã·ûJBSTACKPUSHCALLOPERATION;ÊÇÔËËã·ûµÄ»°JMPFIRSTDONE;Èç¹ûÊÇÊý×ÖSTACKPUSH:MOVAH,0;PUSHAXMOVNUMSTACK[BP],ALINCBPINCSI;===========80ÐÐFIRSTDONE:RETFISRTCALCENDP;==================ÅжϲÙ×÷·ûÊÇ·ñ½øÕ»================OPERATIONPROCCALLCONVERTCMPCL,0JEOPNEXT1MOVDL,CL;======90SUBDL,OPSTACKN[DI-1]JBOPNEXT2MOVOPSTACKN[DI],CL;ÔËËã·û¼°ÆäµÈ¼¶½øÕ»MOVOPSTACK[DI],ALINCDIINCSIJMPOPDONEOPNEXT1:MOVDL,OPSTACKN[DI-1]CMPDL,0;======100JNEOPNEXT11MOVAL,NUMSTACK[BP-1]MOVRESULT,ALINCSIJMPOPDONEOPNEXT11:CALLEXECDECDIJMPOPDONEOPNEXT2:CALLEXECDECDIOPDONE:RETOPERATIONENDP;==========½«+¡¢-¡¢*¡¢/ת»¯Îª012==============CONVERTPROC;//0096CMPAL,2BHJEPLUSCMPAL,2DHJEMINUSCMPAL,2AHJECMULCMPAL,2FHJECDIVCMPAL,0DHJECENDPLUS:MOVCL,1JMPCONVERTDONEMINUS:MOVCL,1JMPCONVERTDONECMUL:MOVCL,2JMPCONVERTDONECDIV:MOVCL,2JMPCONVERTDONECEND:MOVCL,0CONVERTDONE:RETCONVERTENDP;=================³öÕ»Ö´ÐÐ=================EXECPROCMOVBL,NUMSTACK[BP-1]MOVAL,NUMSTACK[BP-2]DECBPMOVDL,OPSTACK[DI-1]CMPDL,2BHJEEXECPLUSCMPDL,2DHJEEXECMINUSCMPDL,2AHJEEXECMULCMPDL,2FHJEEXECDIVEXECPLUS:ADDAL,BLJMPEXECDONEEXECMINUS:SUBAL,BLJMPEXECDONEEXECMUL:MOVAH,0MULBLJMPEXECDONEEXECDIV:MOVAH,0DIVBLEXECDONE:MOVNUMSTACK[BP-1],ALRETEXECENDPCODEENDSENDSTART
本文标题:汇编语言编写的四则运算计算机
链接地址:https://www.777doc.com/doc-4411658 .html