微机原理课程设计_计算器设计_汇编课程设计|精品课程网站设计|课程设计网报告总结心得
执行时,需在文件名后直接跟上计算表达式,如在命令提示符下执行结果如下:c:\masm>js 3+2
5c:\masm>js 6*7
2Ac:\masm>js 10-4
cc:\masm>js 12/3
6B_P EQU BYTE PTRW_P EQU WORD PTRD_P EQU DWORD PTRCODE SEGMENTASSUME CS:CODE,DS:CODEORG 100H;主程序开始NEWSTAR:JMP STAREVENNUM1 DW 0,0NUM2 DW 0,0NUM3 DW 0,0JGV4 DW 0,0YSF LABEL WORDYSF1 DB 0YSF2 DB 0JUV DB 0UV DB 0;使DS:SI指向第一有效字符OVERS LABEL NEARCLDPUSH AXOVERS1:LODSBCMP AL,' 'JZ OVERS1CMP AL,9JZ OVERS1DEC SICMP AL,13POP AXRET;输出一个制表符TAB LABEL NEARMOV AL,9JMP SHORT DISP;输出一个回车换行符CRLF LABEL NEARMOV AL,13CALL DISPMOV AL,10;显示一个字符DISP LABEL NEARPUSH AXPUSH DXMOV AH,2MOV DL,ALINT 21HPOP DXPOP AXRET;检查是否为运算符ISYSF LABEL NEARCLDLODSBCALL ISJJJZ ISYSF1CALL ISIIJZ ISYSF1DEC SIISYSF1:RET;检查是否是加减运算ISJJ LABEL NEARCMP AL,'+'JZ ISYSF1CMP AL,'-'RET;检查是否为乘除运算ISII LABEL NEARCMP AL,'*'JZ ISYSF1CMP AL,'/'JZ ISYSF1CMP AL,'\'RET;数据输出;CX=10 十进制;CX=16 十六进制DOUT LABEL NEARPUSH AXPUSH BXPUSH DXPUSH BPXOR BP,BPDOUT1:INC BPPUSH AXMOV AX,DXXOR DX,DXDIV CXMOV BX,AXPOP AXDIV CXPUSH DXMOV DX,BXOR BX,AXJNZ DOUT1DOUT2:POP AXADD AL,'0'CMP AL,'9'JBE DOUT3ADD AL,'A'-'9'-1DOUT3:CALL DISPDEC BPJNZ DOUT2POP BPPOP DXPOP BXPOP AXRET;输入数据在DX:AX中返回;CX=0 数据为10进制;CX#0 数据为16进制DATE LABEL NEARPUSH BXPUSH BPPUSH DIXOR AX,AXXOR DX,DXDATE1:MOV DI,AXLODSBCMP AL,'0'JB DATE7CMP AL,'9'JA DATE6DATE2:AND AX,0FHSHL DI,1RCL DX,1MOV BX,DIMOV BP,DXSHL DI,1RCL DX,1SHL DI,1RCL DX,1JCXZ DATE3SHL DI,1RCL DX,1Jmp short DATE4DATE3:ADD DI,BXADC DX,BPDATE4:ADD AX,DIADC DX,0JMP DATE1DATE5:ADD AL,9JMP DATE2DATE6:JCXZ DATE7CMP AL,'A'JB DATE7CMP AL,'F'JBE DATE5CMP AL,'a'JB DATE7CMP AL,'f'JBE DATE5DATE7:MOV AX,DIDEC SIOR DI,DXPOP DIPOP BPPOP BXRET;数据1与数据2根据YSF1进行加减运算JSJJ LABEL NEARMOV AX,NUM2MOV DX,NUM2+2CMP YSF1,'+'JZ JSJJ1SUB NUM1,AXSBB NUM1+2,DXJMP SHORT JSJJ2JSJJ1:ADD NUM1,AXADC NUM1+2,DXJSJJ2:RET;数据1与数据2根据YSF1进行乘除运算JSII1 LABEL NEARMOV BX,OFFSET NUM1JMP SHORT JSII2_1;数据2与数据3根据YSF2进行乘除运算JSII2 LABEL NEARMOV BX,OFFSET NUM2JSII2_1:DB 66HMOV AX,[BX]DB 66HMOV CX,[BX+4]CMP YSF2,'*'JNZ JSII2_2DB 66HIMUL CXJMP SHORT JSII2_3JSII2_2:DB 66HCWDDB 66HIDIV CXCMP YSF2,'/'JZ JSII2_3DB 66HXCHG DX,AXJSII2_3:DB 66HMOV [BX],AXRET