I mooved to register al number -100, now in al stored 9C in hexademical, the same thing I did with register bl, so in bl stored 9C too. And here is the problem, when I do:
imul ebx
I get 00005F10h in register eax, it's 24336 in decimal instead of 10000 that I was expected to get. What am I doing wrong? Here is the part of code where I do this multiplication:
mov eax, 0
mov ebx, 0
mov ecx, 0
mov al, [sbAval+esi]
mov bl, [sbAval+esi]
power:
imul ebx
cmp ecx, 2
je powerDone
inc ecx
jmp power
sbAval is SBYTE data type
Here I have 9C stored in eax and ebx registers before imul
And here is registers after imul registers after imul
movsx eax, byte ptr [sbAval+esi]
in place ofmov al, ...
, and likewisemovsx ebx, ...
– Nate Eldredgeimul eax, ebx
(or use any registers, like EDX for the copy, so you don't have to save/restore a call-preserved register like EBX). Also, why load from memory twice? Justmov edx, eax
after doing one movsx load. (If you didn't need to multiply repeatedly, you could have usedimul al
to square into AX.) – Peter Cordes