I usually translate 0xNNN... hexanumbers like &h0NNN..., that makes them unsigned. But in this case it does not seem to do difference.
But I think your code works, except the first line, where your duplication of N makes trouble.
I would write it as:
Local n As Integer = 32
While Not ( ANDB(x, &h080000000)) And (n > 0)
SHIFT LEFT x,1
... as ThinBasic has return as well.