小弟是个新手,刚开始学习汇编,还不太明白,望哪位大哥帮忙写个汇编编写的计算器程序以供参考,小弟不胜感激啊!!!
只有+ - * / 也行!
主要是要有小数功能,有4位小数
这个你看看
不知道还来的及不!
输入格式:34-45=
05*23=
两位的运算,要是一位运算,高位补0.
安回车退出程序
CSEG SEGMENT
ASSUME CS:CSEG
START: MOV AH,01H
INT 21H
CMP AL,0DH
JE JS1
SUB AL,30H
MOV BL,0AH
MUL BL
MOV BL,AL
MOV AH,01H
INT 21H
SUB AL,30H
ADD AL,BL
XOR AH,AH
MOV CX,AX
SHURU: MOV AH,01H
INT 21H
CMP AL,'+'
JE JIA
CMP AL,'-'
JE JIAN
CMP AL,'*'
JE CHENG
CMP AL,'/'
JE CHU
CMP AL,'='
JE JIEGUO
JMP JIEGUO
JS1: JMP JS2
JIA: MOV AH,01H
INT 21H
SUB AL,30H
MOV BL,0AH
MUL BL
MOV BL,AL
MOV AH,01H
INT 21H
SUB AL,30H
ADD AL,BL
XOR AH,AH
ADD CX,AX
JMP SHURU
JIAN: MOV AH,01H
INT 21H
SUB AL,30H
MOV BL,0AH
MUL BL
MOV BL,AL
MOV AH,01H
INT 21H
SUB AL,30H
ADD AL,BL
XOR AH,AH
SUB CX,AX
JMP SHURU
CHENG: MOV AH,01H
INT 21H
SUB AL,30H
MOV BL,0AH
MUL BL
MOV BL,AL
MOV AH,01H
INT 21H
SUB AL,30H
ADD AL,BL
MOV BH,AL
MOV AX,CX
MUL BH
MOV CX,AX
JMP SHURU
CHU: MOV AH,01H
INT 21H
SUB AL,30H
MOV BL,0AH
MUL BL
MOV BL,AL
MOV AH,01H
INT 21H
SUB AL,30H
ADD AL,BL
MOV BH,AL
MOV AX,CX
DIV BH
MOV CL,AL
XOR CH,CH
JMP SHURU
JS2: JMP JIESHU
JIEGUO: CMP CX,0
JGE BXYL
NEG CX
MOV DL,'-'
MOV AH,02H
INT 21H
BXYL: XOR DI,DI
MOV AX,CX
XOR DX,DX
MOV BX,1000
DIV BX
MOV CX,DX
CMP AL,0
JE OK1
ADD AL,30H
MOV DL,AL
MOV AH,02H
INT 21H
INC DI
OK1: MOV BX,100
MOV AX,CX
XOR DX,DX
DIV BX
MOV CX,DX
CMP DI,0
JNE OK2
CMP AL,0
JE OK3
OK2: ADD AL,30H
MOV DL,AL
MOV AH,02H
INT 21H
INC DI
OK3: MOV BL,10
MOV AX,CX
DIV BL
MOV BL,AH
CMP DI,0
JNE OK4
INC DI
CMP AL,0
JE OK5
OK4: ADD AL,30H
MOV DL,AL
MOV AH,02H
INT 21H
OK5: ADD BL,30H
MOV DL,BL
MOV AH,02H
INT 21H
MOV DL,0DH
MOV AH,02H
INT 21H
MOV DL,0AH
MOV AH,02H
INT 21H
JMP START
JIESHU: MOV AH,04CH
INT 21H
CSEG ENDS
END START