1 STA SEGMENT STACK
2 DW 60H DUP(?)
3 TOP LABEL WORD
4 STA ENDS
5
6 DATA SEGMENT
7
8 CRLF DB 0DH,0AH,24H
9
10 DATA ENDS
11
12 CODE SEGMENT
13
14 ASSUME CS:CODE,SS:STA,DS:DATA
15
16 MAIN PROC FAR
17 MOV AX,STA
18 MOV SS,AX
19 LEA SP,TOP
20 MOV AX,DATA
21 MOV DS,AX
22
23 MOV CX,5
24 XOR BX,BX
25 MOV AH,1
26 INT 21H
27 CMP AL,30H
28 JB L99
29 CMP AL,39H
30 JA L155
31
32
33 AND AX,0FH ;0000 0000 0000 1111
34 XCHG AX,BX
35 MOV SI,10
36 MUL SI
37 ADD BX,AX
38 MOV CX,4
39 L100:MOV AH,1
40 INT 21H
41 CMP AL,0DH
42 JE L82
43 CMP AL,30H
44 JB L100
45 CMP AL,39H
46 JA L100
47
48 AND AX,0FH ;0000 0000 0000 1111
49 XCHG AX,BX
50 MOV SI,10
51 MUL SI
52 ADD BX,AX
53 LOOP L100
54
55 L82:
56 JMP L20
57
58
59
60 L99:CMP AL,'+'
61 JE L10 ;跳到整数部分
62
63 CMP AL,'-'
64 JE L11
65
66 L155: JMP L15
67
68 L10:
69 MOV AH,1
70 INT 21H
71 CMP AL,0DH
72 JE L12
73 CMP AL,30H
74 JB L10
75 CMP AL,39H
76 JA L10
77
78 AND AX,0FH ;0000 0000 0000 1111
79 XCHG AX,BX
80 MOV SI,10
81 MUL SI
82 ADD BX,AX
83 LOOP L10
84
85 L12:
86 JMP L20
87
88 L11:
89
90 MOV AH,1
91 INT 21H
92 CMP AL,0DH
93 JE L19
94 CMP AL,30H
95 JB L11
96 CMP AL,39H
97 JA L11
98
99 AND AX,0FH ;0000 0000 0000 1111
100 XCHG AX,BX
101 MOV SI,10
102 MUL SI
103 ADD BX,AX
104 LOOP L11
105
106 L19:NEG BX
107 JMP L20
108
109 L20:
110 MOV AH,9
111 LEA DX,CRLF
112 INT 21H
113 MOV CX,4
114 L23:
115 MOV DL,30H
116 PUSH CX
117 MOV CL,4
118 ROL BX,CL
119 MOV AL,BL
120 AND AL,0FH
121 CMP AL,9
122 JNA L24
123 ADD AL,7
124 L24:
125 ADD DL,AL
126 MOV AH,2
127 INT 21H
128 POP CX
129 LOOP L23
130 L15:
131 MOV AH,4CH
132 INT 21H
133 MAIN ENDP
134 CODE ENDS
135 END MAIN
136
137
138
139
140