-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhex_to_bin_to_led.asm
146 lines (97 loc) · 3.07 KB
/
hex_to_bin_to_led.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
;2031 DIMITRIOS CHARISTES
#start=led_display.exe#
TITLE HEX2BIN_LED
DATA SEGMENT
count db 0
hex_num db 10,13, "Input the hex number (exit by typing "."): $"
bin_result db 10,13, "In binary: $"
DATA ENDS
CODE SEGMENT
START:
MOV AX, DATA
MOV DS, AX
call get_two_hex_digits
call output_value_to_display
EXIT:
MOV AH, 4Ch
INT 21h
get_two_hex_digits proc
mov count,0
call get_one_hex_digit
mov count,1
call get_one_hex_digit
ret
get_two_hex_digits endp
get_one_hex_digit proc
hex_to_bin:
cmp count,1
je input
lea dx, hex_num
mov ah,09
int 21h
mov bx, 0
input:
mov ah,08h
int 21h
cmp al,"."
je EXIT
skip:
cmp al,"A"
jl decimal
cmp al, "F"
jg input
mov dl,al
mov ah,02h
int 21h
add al,09h
jmp process
decimal:
cmp al,39h
jg input
cmp al,30h
jl input
mov dl,al
mov ah,02h
int 21h
jmp process
process:
and al,0Fh
mov cl, 04
shl al,cl
loop1:
shl al,1
rcl bx,1
loop loop1
END:
ret
get_one_hex_digit endp
output_value_to_display proc
mov ax,0
push ax
lea dx, bin_result
mov ah,09
int 21h
mov cx,08
loop2:
pop ax
shl bl,01
jc one
mov dl,30h
shl al,1
out 199,ax
jmp display
one:
mov dl,31h
rcl al,1
out 199,ax
display:
push ax
mov ah,02
int 21h
loop loop2
pop ax
ret
output_value_to_display endp
jmp EXIT
CODE ENDS
END START