initial commit: a mess of assembly code
[fmap.git] / x86_64_sse2_x87 / pbf / blk / hdr / text.s
blobe6bc583a94a989c8b7ddfc863091499b01f8c160
1 ; vim: set filetype=fasm foldmethod=marker commentstring=;%s colorcolumn=101 :
2 hdr: namespace hdr
3 ; we don't follow specs: we will try to go best effort in blk_primitive parsing
4 ; scratch: rax rcx r11 r9
5 ; from blk
6 define p rbx ; in
7 define p_finish r12 ; in
8 ;define flags r15 ; in/out
9 align_nops
10 parse:
11 .key_next:
12 cmp p, p_finish
13 je blob.hdr.parse.return_from_blk
14 varint_load r11, p ; key
15 mov r9, r11; = copy key
16 shr r11, 3 ; = field num
17 ; print strings we are aware of
18 cmp r11, 4 ; field num = HeaderBlock.required_features (see specs) ?
19 je .str_print
20 cmp r11, 5 ; field num = HeaderBlock.optional_features (see specs) ?
21 je .str_print
22 cmp r11, 16 ; field num = HeaderBlock.writingprogram (see specs) ?
23 je .str_print
24 cmp r11, 17 ; field num = HeaderBlock.source (see specs) ?
25 je .str_print
26 cmp r11, 34 ; field num = HeaderBlock.osmosis_replication_base_url (see specs) ?
27 je .str_print
28 and r9, 111b ; = field type
29 TRACE 'PBF:BLK:HDR:MSG:FIELD %lu OF TYPE %lu', r11, r9
30 val_skip p, r9, r11
31 jmp .key_next
32 align_nops
33 .str_print:
34 varint_load r9, p ; = str_sz
35 TRACE 'PBF:BLK:HDR:MSG:STRING %lu of VALUE "%.*s"', r11, r9, p
36 add p, r9 ; skip the str val
37 jmp .key_next
38 ;---------------------------------------------------------------------------------------------------
39 purge p
40 purge p_finish
41 ;purge flags
42 end namespace ; hdr