Subject: [rohc] Mnemonic code for DEFLATE

From: "Price, Richard" <[email-masked]>
Date: Tue, 12 Mar 2002 10:17:08 -0000

Hi,

We've recently put together some mnemonic code for DEFLATE compression
as per RFC 1951, which may be of use when testing implementations of
SigComp:

reserve uncompressed_pointer
reserve length_table 116
reserve distance_table 120
reserve index
reserve extra_length_bits
reserve length_value
reserve extra_distance_bits
reserve distance_value
reserve circular_buffer 2048

NBO
INPUT-FIXED 3 extra_length_bits fail
MULTILOAD 0 122 circular_buffer reserved_end 0 circular_buffer

; this is the length table

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

; this is the distance table

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       767     9       1025
9       1537    10      2049    10      3073
11      4097    11      6145    12      8193
12      12289   13      16385   13      24577

:next_character

INPUT-HUFFMAN index end_of_message 4 7 0 23 16385 1 48 191
              0 0 192 199 16409 1 400 511 144
COMPARE $index 16385 literal end_of_message length_distance

:literal

COPY-LITERAL index.LSB 1 $uncompressed_pointer
OUTPUT index.LSB 1
JUMP next_character

:length_distance

; this is the length part

MULTIPLY $index 4
COPY $index 4 extra_length_bits
INPUT-FIXED $extra_length_bits extra_length_bits fail
ADD $length_value $extra_length_bits

; this is the distance part

INPUT-HUFFMAN index fail 1 5 0 31 31
MULTIPLY $index 4
COPY $index 4 extra_distance_bits
INPUT-FIXED $extra_distance_bits extra_distance_bits fail
ADD $distance_value $extra_distance_bits
COPY uncompressed_pointer 2 index
COPY-OFFSET $distance_value $length_value $uncompressed_pointer
OUTPUT $index $length_value
JUMP next_character

:fail

DECOMPRESSION-FAILURE

:end_of_message

END-MESSAGE 9 0 total_length next_character 0

Our assembler produces the following bytecode, which needs to be copied into the
UDVM memory beginning at Address 2302, and then executed starting from the same
address:

181a 03a0 f6a1 1e0c 007a a0fe 8008 fd00 a0fe 0003 0004 0005 0006 0007 0008 0009
000a 010b 010d 010f 0111 0213 0217 021b 021f 0323 032b 0333 033b 04a0 4304 a053
04a0 6304 a073 05a0 8305 a0a3 05a0 c305 a0e3 00a1 0200 0100 0200 0300 0401 0501
0702 0902 0d03 1103 1904 2104 3105 a041 05a0 6106 a081 06a0 c107 a101 07a1 8108
a201 08a2 ff09 a401 09a6 010a a801 0aac 010b b001 0bb8 010c 8020 010c 8030 010d
8040 010d 8060 011b a0f4 a079 0407 0017 8040 0101 30a0 bf00 00a0 c0a0 c780 4019
01a1 90a1 ffa0 9011 c0f4 8040 010a a059 160e a0f5 0103 17a0 f501 109f cd06 7a04
0dc0 f404 a0f6 1ac0 f6a0 f639 047c c0f6 1ba0 f42f 0105 001f 1f06 7a04 0dc0 f404
a0fa 1ac0 faa0 fa1d 047e c0fa 0d06 02a0 f40f c0fc c0f8 0317 c0f4 c0f8 109f 8b00
1609 0080 0a27 a9a5

Here's a compressed message to test the above bytecode:

0bc9 c82c 5600 a244 8592 d4e2 1285 dcd4 e2e2 c4f4 543d 0585 f08c c412 9044 4946
aa42 625e 7179 6a91 4249 be42 4e66 5aaa 0e58 ac34 2fb3 2cb5 a818 2499 a290 0a64
5696 6464 e6a5 db73 0100 0000 00ff ff00

Regards,

Richard