我需要2位,从位数组的偏移量6。
mov eax, [bitarray]; // get address of bit array
shr eax, 6; // clear first 6 bits
shl eax, 30 // clear last 30 bits
shr eax, 30; // move that 2 bits back to start
现在在eax中是我需要的2位,对吗?
当我的内存从0开始(一个单元是一个比特),那么位置0的比特将在加载到寄存器eax的最右边的位置或最左边的位置之后?
发布于 2013-05-24 15:19:51
您可以使用逐位AND
来代替末尾的两个移位
AND EAX,3 ; Keep the original value of the two least significant bits; all
; other bits in EAX are cleared.
最左边的位是最高有效位,最右边的位是最低有效位。
发布于 2013-05-24 17:01:54
mov eax,位数组
位掩码?
mov eax,[bitarray]
mov ebx,C0 ;11000000 binary
and ax,bx
https://stackoverflow.com/questions/16738243
复制