the whole setup is inefficient  i think you should just start with and  rot  rhs asregister register shifteroperand  x f lsrs tmp  rhs asregister register carry rhs x rsb tmp  rot  shifteroperand  x al  kcckeep preserve carry  if  is left b  right  cs else b  right  cc std  swap rot  tmp and exchange the  rot  and  tmp  in the  right  branch  drop this mov  the and below and both rsb below it would make sense to rename variables rot  shift left  tmp  shift right 