Reputation: 2607
I have made a procedure that multiplies 2 numbers using add and shift method and stores the result in a buff variable.
Here, buff1 and buff2 are initialised in the data section of the code as word type.
buff1 dw 0AH
buff2 dw 03H
And buff is declared in .bss section as 4 byte.
buff resb 4
Here is the procedure that does the multiplication :
shift_add:
movzx eax,word[buff1] ;2byte
movzx ebx,word[buff2]
mov edx,0H
mov rcx,16 ;integer
backs:
shr bl,1
jnc haha
add edx,eax
haha:
shl eax,1
loop backs
mov dword[buff],edx
print buff,4
ret
Why is the above code giving me garbage output ?enter image description here
Upvotes: 0
Views: 114