Bevilacqua
Bevilacqua

Reputation: 475

DCPU-16 Bitwise Shifting

I am trying to learn DCPU.

;Set b to 1
SET B,1 ;00001 (1)
SHL B,1 ;00010 (2)
SHL B,1 ;00100 (4)
SHL B,1 ;01000 (8)
SHL B,1 ;10000 (16)

All I am doing is shifting to the left one so shouldn't it simply double itself each shift. In my code you can see i have the last shift turning the registry B into 16 but when ran B ends up as 10 why is that.

Upvotes: 1

Views: 311

Answers (1)

the register window says 0x0010...

You're getting the correct answer, you're just viewing it in hexadecimal.

Numbers starting with 0x are the standard way of signifying a hexadecimal number; so the number 0x0010 is is really the number 1016 ("one-zero in base sixteen"), which, in decimal, is the number sixteen.

Upvotes: 7

Related Questions