-
Notifications
You must be signed in to change notification settings - Fork 5
/
U8.fm
113 lines (89 loc) · 1.98 KB
/
U8.fm
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
T U8
| U8.new(a: Word(8));
U8.0: U8
U8.new(Word.zero(8))
U8.add(a: U8, b: U8): U8
get a_val = a
get b_val = b
U8.new(Word.add<>(a_val, b_val))
U8.and(a: U8, b: U8): U8
get a_val = a
get b_val = b
U8.new(Word.and<>(a_val, b_val))
U8.concat(a: U8, b: U8): U16
get a_val = a
get b_val = b
U16.new(Word.concat<><>(a_val, b_val))
U8.div(a: U8, b: U8): U8
get a_val = a
get b_val = b
U8.new(Word.div<>(a_val, b_val))
// a == b
U8.eql(a: U8, b: U8): Bool
get a_val = a
get b_val = b
Word.eql<>(a_val, b_val)
// a >= b
U8.gte(a: U8, b: U8): Bool
get a_val = a
get b_val = b
Word.gte<>(a_val, b_val)
// a > b
U8.gtn(a: U8, b: U8): Bool
get a_val = a
get b_val = b
Word.gtn<>(a_val, b_val)
U8.inc(a: U8): U8
get a_val = a
U8.new(Word.inc<>(a_val))
// a <= b
U8.lte(a: U8, b: U8): Bool
get a_val = a
get b_val = b
Word.lte<>(a_val, b_val)
// a < b
U8.ltn(a: U8, b: U8): Bool
get a_val = a
get b_val = b
Word.ltn<>(a_val, b_val)
U8.mod(a: U8, b: U8): U8
get a_val = a
get b_val = b
U8.new(Word.mod<>(a_val, b_val))
U8.mul(a: U8, b: U8): U8
get a_val = a
get b_val = b
U8.new(Word.mul<>(a_val, b_val))
U8.or(a: U8, b: U8): U8
get a_val = a
get b_val = b
U8.new(Word.or<>(a_val, b_val))
U8.parse_hex(str: String): U8
U8.new(Word.from_bits(8, Bits.parse_hex(str)))
U8.pow(a: U8, b: U8): U8
get a_val = a
get b_val = b
U8.new(Word.pow<>(a_val, b_val))
U8.shl(n: Nat, a: U8): U8
get a_val = a
U8.new(Word.shift_left<>(n, a_val))
U8.shr(n: Nat, a: U8): U8
get a_val = a
U8.new(Word.shift_right<>(n, a_val))
U8.sub(a: U8, b: U8): U8
get a_val = a
get b_val = b
U8.new(Word.sub<>(a_val, b_val))
U8.to_bits(a: U8): Bits
get a_val = a
Word.to_bits<>(a_val)
U8.to_nat(a: U8): Nat
get a_val = a
Word.to_nat<>(a_val)
U8.xor(a: U8, b: U8): U8
get a_val = a
get b_val = b
U8.new(Word.xor<>(a_val, b_val))
U8.from_nat(n: Nat): U8
// TODO
U8.parse_hex(Nat.to_string_base(16, n))