-
Notifications
You must be signed in to change notification settings - Fork 0
/
HexOperate.asm
208 lines (157 loc) · 3.52 KB
/
HexOperate.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
TITLE HEX_OPERATE
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
MAIN PROC
MOV AX,DATA
MOV DS,AX
LEA DX,WELCOME
MOV AH,9
INT 21H
INOPUT1:
LEA DX,MESSAGE
MOV AH,9
INT 21H
MOV AH,08
INT 21H
CMP AL,'0'
JB INOPUT1
CMP AL,'9'
JBE STORE1
CMP AL,'A'
JB INOPUT1
CMP AL,'F'
JA INOPUT1
STORE1:
MOV BL,AL ;EMFANISE TON PROTO ARITHMO
MOV DL,BL
MOV AH,02
INT 21H
CMP BL,'9' ;KANTON ARITHMO
JBE NUMBER
SUB BL,48
SUB BL,7
JMP NEXT1 ;PANE STO DEUTERO DIAVASMA
NUMBER:
SUB BL,48
NEXT1:
INPUT2:
LEA DX,MESSAGE ;ZITA DEUTERO ARITHMO
MOV AH,9
INT 21H
MOV AH,08
INT 21H
CMP AL,'0'
JB INPUT2
CMP AL,'9'
JBE STORE2
CMP AL,'A'
JB INPUT2
CMP AL,'F'
JA INPUT2
STORE2:
MOV BH,AL ;EMFANISE TON DEUTERO ARITHMO
MOV DL,BH
MOV AH,02
INT 21H
CMP BH,'9' ;KANTON ARITHMO
JBE NUMBER2
SUB BH,48
SUB BH,7
JMP NEXT2
NUMBER2:
SUB BH,48
NEXT2: ;DIAVASE TON OPERATOR
INPUT_OPERATOR:
LEA DX,OPERATOR
MOV AH,9
INT 21H
MOV AH,08
INT 21H
CMP AL,'+'
JE STORE3
CMP AL,'*'
JE STORE3
JMP INPUT_OPERATOR
STORE3:
MOV CH,AL ;EMFANISE TON OPERATOR
MOV DL,CH
MOV AH,02
INT 21H
PRINT:
LEA DX,NEWLINE
MOV AH,09
INT 21H
CMP CH,'+'
JE ADD_OPERATOR
MOV AH,0
MOV AL,BL
MUL BH
MOV BL,AL
JMP NEXT3
ADD_OPERATOR:
MOV AL,BL
ADD AL,BH
MOV BL,AL
NEXT3: ;O BL EXEI TON PROTO,O BH EXEI TON DEUTERO,O CH EXEI TO OPERATOR
CALL DISPLAY_DEC ;O BL EXEI TO APOTELESMA
MOV AH,4CH
INT 21H
MAIN ENDP
DISPLAY_DEC PROC
CMP BL,99 ;O BL EXEI TON ARITHMO
JA TRIPSIFIOS
CMP BL,9
JA DIPSIFIOS
MOV DL,BL ;MONOPSIFIOS
ADD DL,48
MOV AH,02
INT 21H
JMP TELOS
DIPSIFIOS:
MOV CL,10
MOV AH,0
MOV AL,BL
DIV CL
MOV BL,AL
MOV BH,AH
MOV DL,BL
ADD DL,48
MOV AH,02
INT 21H
MOV DL,BH
ADD DL,48
MOV AH,02
INT 21H
JMP TELOS
TRIPSIFIOS:
MOV CL,10
MOV AL,BL
DIV CL
MOV BH,AH ;TO 3O PSIFIO
MOV AH,0 ;ARXIKOPOIHSE
DIV CL
MOV CH,AH ;TO 2O PSIFIO
MOV CL,AL ;TO 1O PSIFIO
MOV DL,CL
ADD DL,48
MOV AH,02
INT 21H
MOV DL,CH
ADD DL,48
MOV AH,02
INT 21H
MOV DL,BH
ADD DL,48
MOV AH,02
INT 21H
TELOS:
RET
DISPLAY_DEC ENDP
DATA SEGMENT
WELCOME DB 10,13," --== WELCOME ==--$"
MESSAGE DB 10,13,"Please give a hexadecimal (0-9 A-F): $"
NEWLINE DB 10,13,"$"
OPERATOR DB 10,13,"Please type the operation between those two hex ( + OR * ) : $"
NOINPUTMIN DB "NO INPUT!!!$"
DATA ENDS
END CODE