Remove more disassembler bogosity
[sbcl.git] / src / runtime / sc-offset.c
bloba0844d98f3133bcccf03a1d377ef86da76fd695e
1 /*
2 * Decoding SC offsets.
3 */
5 /*
6 * This software is part of the SBCL system. See the README file for
7 * more information.
9 * This software is derived from the CMU CL system, which was
10 * written at Carnegie Mellon University and released into the
11 * public domain. The software is in the public domain and is
12 * provided with absolutely no warranty. See the COPYING and CREDITS
13 * files for more information.
16 #include "genesis/sc-offset.h"
18 int
19 sc_offset_extract_bits(int sc_offset,
20 unsigned int bytes_count,
21 struct sc_offset_byte* bytes) {
22 unsigned int result = 0, i = 0, position, size, mask, index = 0;
23 for (; i < bytes_count; ++i, index += size) {
24 position = bytes[i].position;
25 size = bytes[i].size;
26 mask = (1 << size) - 1;
27 result |= ((sc_offset >> position) & mask) << index;
29 return result;
32 int
33 sc_offset_sc_number(int sc_offset) {
34 return sc_offset_extract_bits
35 (sc_offset,
36 sizeof(sc_offset_sc_number_bytes) / sizeof(struct sc_offset_byte),
37 sc_offset_sc_number_bytes);
40 int
41 sc_offset_offset(int sc_offset) {
42 return sc_offset_extract_bits
43 (sc_offset,
44 sizeof(sc_offset_offset_bytes) / sizeof(struct sc_offset_byte),
45 sc_offset_offset_bytes);