Multiplication of large number.
continue equ @r
skip equ @f
BIG_NUM_COUNT = 128 ; 128 DWORD = 4096 bits
;------------------------------------------------
; * * * Multiplication of Big Number * * *
;------------------------------------------------
proc MulBigNumeric result, base, factor
mov ESI, [factor]
mov ECX, BIG_NUM_COUNT
.scan:
lodsd
or EAX, EAX
jz .next
mov EBX, EAX ; EBX = factor[ind++]
push ECX
push ESI
;------------------------------------------------
; result += multiplication + overflow + carry
;------------------------------------------------
mov EDI, [result]
mov ESI, [base]
mov ECX, BIG_NUM_COUNT
push EBP ; The x86 has very few registers
xor EBP, EBP ; carry = 0
@@:
lodsd
mul EBX
add EAX, EBP ; EAX = base * factor + carry
adc EAX,[EDI] ; EAX+= result + carry
stosd
; adz EDX ; non-existent command!
adc EDX, 0 ; overflow += carry
mov EBP, EDX
loop continue
pop EBP ; restore!
;------------------------------------------------
add [result], 4 ; increase the result by an order
pop ESI
pop ECX
.next:
loop .scan
ret
endp