nasm - Assembly shift right with carry in? -
my class using nasm assembly , trying figure out different ways shift, know instructions shr/sar, shl/sal, ror, rcr, rol, rcl. shift right , set leftmost bit whatever want. example:
i have 11010011, , shifting right produce _1101001 cf=1, there shift in can carry in number leftmost bit? thanks!
edit:
my thoughts using bit-wise operations , if leftmost bit isn't want can flip using not operator. example number ends 1 1101001 , wanted 0 1101001,
1 1101001 & 01101001 = 01101001 or, 0 1101001 | 11101001 = 11101001
the easiest way set bit want using , or or operations.
if want high bit set 1, use input or 1000000
.
if want set 0, use input , 01111111
.
the remaining bits unchanged.
Comments
Post a Comment