I want to set the first N bits of a register to 1. For example, if N is 3 then the register would be: ...00000111
. Is there an instruction or short-form way to do this? The way I'm currently doing it is:
mov $0, %eax
test %esi, %esi
jz end
loop:
add $0b1, %eax
dec %esi
jz end_loop
shl %eax
jmp loop
exit:
...