This is the code I have been using to implement extended multiplication of two 32-bit numbers. Is there a way to implement the similar logic by making a subroutine and using stack via parameter passing? Either with MUL instruction or without it ? Can anyone help?
[org 0x0100]
jmp start
multiplicand: dd 123122,0
multiplier: dd 66341
result: dd 0,0
start:
initialize: mov cl,32
mov bl,1
checkbit: test bl,[multiplier]
jz skip
multiply: mov ax, [multiplicand]
add [result],ax
mov ax, [multiplicand+2]
adc [result+2], ax
mov ax, [multiplicand+4]
adc [result+4], ax
mov ax, [multiplicand+6]
adc [result+6], ax
skip: shl bl,1
shr word [multiplier+2],1
rcr word [multiplier],1
shl word [multiplicand],1
rcl word [multiplicand+2],1
rcl word [multiplicand+4],1
rcl word [multiplicand+6],1
dec cl
jnz checkbit
mov ax, 0x4c00
int 0x21
See Question&Answers more detail:os