summaryrefslogtreecommitdiffstats
path: root/tinySIGCOMP/asm/deflate.asm
blob: f9a1469485500fc57c2c27aebc8fac597ec2418e (plain)
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
at (32)
readonly (0)

:index                      pad (2)
:extra_length_bits          pad (2)
:len_value                  pad (2)
:extra_dist_bits            pad (2)
:dist_value                 pad (2)


at (42)

:req_feed_loc                   pad (1)
:req_feed_len                   pad (1)
:req_feed_field                 pad (12)
:hash_start                     pad (8)

at (64)

:byte_copy_left                 pad (2)
:byte_copy_right                pad (2)
:input_bit_order                pad (2)
:decompressed_ptr               pad (2)
:length_table                   pad (116)
:distance_table                 pad (120)

:hash_len_loc                   pad (2)
:state_len_loc                  pad (2)
:ret_params_loc                 pad (1)
:sigcomp_version                pad (1)

align (64)


readonly (1)
:initialize_memory

set (udvm_memory_size, 8192)
set (length_table_start, (((length_table - 4) / 4) + 16384))
set (length_table_mid, (length_table_start + 24))
set (dist_table_start, (distance_table / 4))

MULTILOAD (64, 122, circular_buffer, udvm_memory_size, 5,
circular_buffer,

0,       3,       0,       4,       0,       5,
0,       6,       0,       7,       0,       8,
0,       9,       0,       10,      1,       11,
1,       13,      1,       15,      1,       17,
2,       19,      2,       23,      2,       27,
2,       31,      3,       35,      3,       43,
3,       51,      3,       59,      4,       67,
4,       83,      4,       99,      4,       115,
5,       131,     5,       163,     5,       195,
5,       227,     0,       258,

0,       1,       0,       2,       0,       3,
0,       4,       1,       5,       1,       7,
2,       9,       2,       13,      3,       17,
3,       25,      4,       33,      4,       49,
5,       65,      5,       97,      6,       129,
6,       193,     7,       257,     7,       385,
8,       513,     8,       769,     9,       1025,
9,       1537,    10,      2049,    10,      3073,
11,      4097,    11,      6145,    12,      8193,
12,      12289,   13,      16385,   13,      24577)

; -- hash_len, state_len, params, version, dicts
INPUT-BYTES (6, hash_len_loc, !)
LOAD (66, $state_len_loc)
ADD(66, 64)


:decompress_sigcomp_msg

:start_decomp

INPUT-BITS (3, extra_length_bits, !)

:next_char

INPUT-HUFFMAN (index, end_of_msg, 4,
   7, 0, 23, length_table_start,
   1, 48, 191, 0,
   0, 192, 199, length_table_mid,
   1, 400, 511, 144)
COMPARE ($index, length_table_start, literal, end_of_msg,
length_distance)

:literal

set (index_lsb, (index + 1))

OUTPUT (index_lsb, 1)
COPY-LITERAL (index_lsb, 1, $decompressed_ptr)
JUMP (next_char)

:length_distance

; this is the length part

MULTIPLY ($index, 4)
COPY ($index, 4, extra_length_bits)
INPUT-BITS ($extra_length_bits, extra_length_bits, !)
ADD ($len_value, $extra_length_bits)

; this is the distance part

INPUT-HUFFMAN (index, !, 1, 5, 0, 31, dist_table_start)
MULTIPLY ($index, 4)
COPY ($index, 4, extra_dist_bits)


INPUT-BITS ($extra_dist_bits, extra_dist_bits, !)
ADD ($dist_value, $extra_dist_bits)
LOAD (index, $decompressed_ptr)
COPY-OFFSET ($dist_value, $len_value, $decompressed_ptr)
OUTPUT ($index, $len_value)
JUMP (next_char)

:end_of_msg


LOAD (req_feed_loc, 1158)
MULTILOAD (hash_start, 4, $state_len_loc, 64, decompress_sigcomp_msg, 6)
SHA-1 (hash_start, $hash_len_loc, req_feed_field)

END-MESSAGE (req_feed_loc, ret_params_loc, $state_len_loc, 64, decompress_sigcomp_msg, 6, 0)

readonly (0)
:circular_buffer
OpenPOWER on IntegriCloud