furs

bwm
Login

bwm

Masking

What is a 'mask' ? In programming, a mask determines which bits we want to keep and which bits we want to clear. To do this, the bits we want to keep are anded with the data we are interested in.

In this case a mask is needs to be created from the BitWidth.


Generate a bitfield mask based on a bitWidth: : bwm ( bitWidth -- mask ) bit 1 - ;

Example: 2 bfm bin. 3322222222221111111111 10987654321098765432109876543210 00000000000000000000000000000011

see bwm 0000EC0C: 2301 movs r3 #1 0000EC0E: 40B3 lsls r3 r6 0000EC10: 3B01 subs r3 #1 0000EC12: 461E mov r6 r3 0000EC14: 4770 bx lr Bytes: 10 ok.