( ROTATE             rotate unsigned-number by n bit positions )

need shift
: rotate                          ( un1 n --- un2 )
  over over                       ( make copy of un1 and n)
  shift                           ( shift un1)
  >r                              ( and save result)
  dup 0<                          ( determine rotate direction)
  if
    16 +                          ( right, shift count = n + 16)
  else
    16 -                          ( left,  shift count = n - 16)
  endif
  shift                           ( shift vacated bits)
  r> or                           ( and combine the two results)
;
