struct-bit-slot-spec


Vocabulary
classes.struct

Definition


Methods










M:: struct-bit-slot-spec load-struct-component
( src offset rep field -- dst )
field offset>> 8 mod
:> start field bits>> :> bits start bits + 8 align 8 /i
<iota> 0 ^^load-integer [| dst index |
src offset index + int-rep uchar ^^load-memory-imm
:> byte index 8 * start - :> shift byte shift 0 <
[ shift neg ^^shr-imm ] [ shift ^^shl-imm ] if
dst swap ^^or
] reduce bits cell-bits < [
cell-bits bits - ^^shl-imm cell-bits bits -
field signed?>> [ ^^sar-imm ] [ ^^shr-imm ] if
] when ;



M:: struct-bit-slot-spec store-struct-component
( value src offset rep field -- )
field offset>> 8 mod
:> start field bits>> :> bits start bits + 8 align 8 /i
<iota> [| index |
start index 8 * - 0 max :> low start bits + index 8 * -
8 min :> high 1 high low - shift 1 - low shift
:> mask src offset index +
int-rep uchar ^^load-memory-imm mask bitnot ^^and-imm
:> old index 8 * start - :> shift value shift 0 <
[ shift neg ^^shl-imm ] [ shift ^^shr-imm ] if
mask ^^and-imm old swap ^^or src offset index +
int-rep uchar ##store-memory-imm,
] each ;