-
Notifications
You must be signed in to change notification settings - Fork 4
/
pair_ns.fj
88 lines (71 loc) · 1.85 KB
/
pair_ns.fj
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
ns Pair {
first = 0
len = w
second = .len*dw
size = .len * 2
def init this {
bit.zero .len, this+.first
bit.zero .len, this+.second
}
def add_first this, val {
._.add this+.first, val
}
def add_second this, val {
._.add this+.second, val
}
def add this, src {
.add_first this, src+.first
.add_second this, src+.second
}
def print this {
stl.output '('
._.print_hex_int this+.first
stl.output ','
stl.output ' '
._.print_hex_int this+.second
stl.output ')'
}
def init {
._.init
}
ns _ {
def add dst, src < .add, .ret_reg, .temp1, .temp2 {
bit.xor ..len, .temp2, src
bit.xor_zero ..len, .temp1, dst
stl.fcall .add, .ret_reg
bit.xor_zero ..len, dst, .temp1
bit.zero ..len, .temp2
}
def print_hex_int val < .print_hex_int, .ret_reg, .temp1 {
bit.xor ..len, .temp1, val
stl.fcall .print_hex_int, .ret_reg
bit.xor ..len, .temp1, val
}
def init @ data_end > add, print_hex_int, ret_reg, temp1, temp2 {
;data_end
add:
bit.add ..len, .temp1, .temp2
stl.fret .ret_reg
print_hex_int:
bit.print_hex_int ..len, .temp1, 1
stl.fret .ret_reg
ret_reg: bit.bit 0
temp1: bit.vec ..len, 0
temp2: bit.vec ..len, 0
data_end:
}
}
def swap this {
bit.swap .len, this+.first, this+.second
}
ns prints {
def print_two p1, p2 {
..print p1
stl.output ','
stl.output ' '
stl.output ' '
..print p2
stl.output '\n'
}
}
}