-
Notifications
You must be signed in to change notification settings - Fork 0
/
binary.opp
71 lines (70 loc) · 1.01 KB
/
binary.opp
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
PROC main:
local h$(2), l&, b$(10)
WHILE -1
h$ = ""
l& = 0
dInit "Hex to binary"
IF b$ <> ""
dTEXT h$, b$
ENDIF
dEDIT h$, "Hex", 4
dLONG l&, "Dec", 0, 255
IF DIALOG
IF h$ <> ""
l& = EVAL("&" + h$)
ENDIF
b$ = ""
print l&
IF l& > 127
b$ = b$ + "1"
l& = l& - 128
ELSE
b$ = b$ + "0"
ENDIF
IF l& > 63
b$ = b$ + "1"
l& = l& - 64
ELSE
b$ = b$ + "0"
ENDIF
IF l& > 31
b$ = b$ + "1"
l& = l& - 32
ELSE
b$ = b$ + "0"
ENDIF
IF l& > 15
b$ = b$ + "1"
l& = l& - 16
ELSE
b$ = b$ + "0"
ENDIF
IF l& > 7
b$ = b$ + "1"
l& = l& - 8
ELSE
b$ = b$ + "0"
ENDIF
IF l& > 3
b$ = b$ + "1"
l& = l& - 4
ELSE
b$ = b$ + "0"
ENDIF
IF l& > 1
b$ = b$ + "1"
l& = l& - 2
ELSE
b$ = b$ + "0"
ENDIF
IF l& > 0
b$ = b$ + "1"
l& = l& - 1
ELSE
b$ = b$ + "0"
ENDIF
ELSE
BREAK
ENDIF
ENDWH
ENDP