manipulate-bits ( offset bits step-quot -- quot shift-amount offset' bits' )


Vocabulary
classes.struct.bit-accessors

Inputs
offsetan object
bitsan object
step-quotan object


Outputs
quotan object
shift-amountan object
offset'an object
bits'an object


Definition


:: manipulate-bits
( offset bits step-quot -- quot shift-amount offset' bits' )
offset 8 /mod :> ( i start-bit ) start-bit bits + 8 min
:> end-bit start-bit end-bit ones-between
:> mask end-bit start-bit -
:> used-bits i mask start-bit step-quot
( i mask start-bit -- quot ) call-effect used-bits i 1 + 8 *
bits used-bits - ; inline