Here is the x86 code to get started:
; I'm assuming the number you want to rotate is in ax ; I'm assuming the number of bits to rotate is in cx loop_start: add cx, -1 ; Can only use add, so add -1 jo loop_end ; If cx is < 0 mov bx, ax ; Copy ax into bx add ax, ax ; shift ax left 1 bit and bx, 1000000000000000b ; Test the msb of bx jz loop_start ; if the msb is zero, jump add ax, 1 ; if the msb is one, add one to ax jmp loop_start ; Loop loop_end:
Sparafusile
source share