Reputation: 35
I am using 32-bit x86.
The problem is I cannot shift the bits to the left.
I want to read one byte each time and put it into eax
, but I am messing up with shifting. I cannot move the bits into high order. Any idea?
myStr byte "12345678"
mov ecx, offset myStr
mov dl, myStr[ecx]
sub dl,30h ;convert to real digit
mov al, dl
shl al,4
inc ecx
;eax should look like this end of the operation 12345678
Upvotes: 0
Views: 761
Reputation: 41794
First mov al, dl
will move the entire byte from dl to al, not just a nibble
Second, you just shift al
shl al,4
After the shift, the remaining upper bytes or eax still not be affected. So what you've done is just move sequentially the numbers in myStr to the high nibble of al. That means al will be 16, 32, 48... 128 after each step, and so is eax if the top 3 bytes eax is 0 before. At the end eax should look like 0xXXXXXX80
Upvotes: 1