Simplify
[llpp.git] / be / bo.ml
blob4423337862e735af78e9f1ec72f40b2d342c9880
1 let w8 s pos i = Bytes.set s pos (Char.chr (i land 0xff));;
2 let r8 s pos = Char.code (Bytes.get s pos);;
4 let ordermagic = 'B';;
6 let w16 s pos i =
7 w8 s pos (i lsr 8);
8 w8 s (pos+1) i
9 ;;
11 let w32 s pos i =
12 w16 s pos (i lsr 16);
13 w16 s (pos+2) i
16 let r16 s pos =
17 let rb pos1 = Char.code (Bytes.get s (pos + pos1)) in
18 (rb 1) lor ((rb 0) lsl 8)
21 let r16s s pos =
22 let i = r16 s pos in
23 i - ((i land 0x8000) lsl 1)
26 let r32 s pos =
27 let u = r16 s pos in
28 let l = r16 s (pos+2) in
29 (u lsl 16) lor l