-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConverter.asm
177 lines (122 loc) · 2.92 KB
/
Converter.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
TITLE CONVERTER
KODIKAS SEGMENT
ASSUME CS:KODIKAS, DS:DATA
CODE:
MOV AX,DATA
MOV DS,AX
LEA DX,WELCOME
MOV AH,9
INT 21H
LEA DX,MESSAGE
MOV AH,9
INT 21H
MOV SI,0
EISAGOGI:
MOV AH,08
INT 21H
CMP AL,'0'
JE STORE
CMP AL,'1'
JE STORE
MOV DL,07
MOV AH,02
INT 21H
MOV DL,07
MOV AH,02
INT 21H
MOV DL,07
MOV AH,02
INT 21H
JMP EISAGOGI
STORE:
MOV BUFFER[SI],AL
INC SI
MOV DL,AL
MOV AH,02
INT 21H
CMP SI,8
JB EISAGOGI
EMFANISI:
LEA DX,NEWLINE
MOV AH,09
INT 21H
MOV CX,SI
JCXZ NOINPUT
MOV BL,0 ;sum
MOV DH,1 ;krataei tin dinami tis thesis
MOV BH,2 ;polaplasiastis
SUB SI,1 ;trexo ton pinaka (counter)
FOR:
CMP BUFFER[SI],'1' ;an einai 1 tote pros8ese
JNE NEXT
ADD BL,DH ;AUKSISE TO SUM
NEXT: ;alios au3ise tin dinami kata 2*progioumeno
MOV AL,DH
MUL BH
MOV DH,AL
DEC SI
LOOP FOR
CMP BL,99
JBE DIPSIFIOS:
MOV AH,0
MOV AL,BL
MOV CL,10
DIV CL
MOV BH,AH ;EXI TO TELEUTAIO PSIFIO
MOV AH,0
DIV CL
MOV CL,AL ;1o PSIFIO
MOV CH,AH ;2o 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
JMP FINISH
DIPSIFIOS:
CMP BL,9
JBE MONOPSIFIOS:
MOV AH,0
MOV AL,BL
MOV CL,10
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 FINISH
MONOPSIFIOS:
MOV DL,BL
ADD DL,48
MOV AH,02
INT 21H
JMP FINISH
NOINPUT:
LEA DX,NOINPUTMIN
MOV AH,09
INT 21H
FINISH:
MOV AH,4CH
INT 21H
KODIKAS ENDS
DATA SEGMENT
WELCOME DB "--== WELCOME ==--$",10,13
MESSAGE DB 10,13,"Please give an 8length binary input: $"
NEWLINE DB 10,13,"$"
NOINPUTMIN DB "NO INPUT!!!$"
BUFFER DB 8 DUP(0)
DATA ENDS
END CODE