Skip to content

Commit da83c3c

Browse files
committed
finally calculation of UInt64_Mul is correct
1 parent 869d07e commit da83c3c

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

Forms/Form1.frm

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -353,17 +353,16 @@ Sub TestDll()
353353

354354
d = UInt64_Mul(c1, c2)
355355
Debug_Print VarType(d) & " " & CStr(d) '14 121932631112635269
356-
357-
'628239210217683
358-
'41419963890366
359-
360-
c1 = 214748.3647 '1234.5678 '62823921021.7683
361-
c2 = 214748.3647 '4141996389.0366
362-
'2147483647*2147483647=4611686014132420609
363-
356+
357+
' 2147483647 * 2147483647 = 4611686014132420609
358+
'c1 = 214748.3647
359+
'c2 = 214748.3647
360+
361+
'628239210217683 * 41419963890366 = 26021645401728484450406541978
362+
c1 = 62823921021.7683
363+
c2 = 4141996389.0366
364364
d = UInt64_Mul(c1, c2)
365-
Debug_Print VarType(d) & " " & CStr(d) '14 26021645401728484450406541978
366-
'
365+
Debug_Print VarType(d) & " " & CStr(d)
367366

368367
s = Space(20): UInt64_ToHex cret, StrPtr(s)
369368
Debug_Print Trim0(s)

UnsignedOpsDll/UnsignedOps.asm

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,9 @@ UInt64_Sub endp
351351
; ByVal V1 As Currency, ByVal V2 As Currency, ByVal pDec_out As LongPtr
352352
UInt64_Mul proc
353353
354-
;int 3
355-
356-
; 1. prepare Variant as type Decimal
354+
;int 3
355+
356+
; 1. prepare Variant as type Decimal
357357
mov edi , [esp+20] ; copy the pointer to a Variant from stack to register EDI
358358
mov dx , 14 ; copy the vartype-word for decimal it is 14 = &HE to the register dx
359359
mov [edi+ 0], dx ; copy the value in register dx to the Variant to the first int16-slot
@@ -389,8 +389,10 @@ UInt64_Mul proc
389389
pushfd ; Save carry out here.
390390
391391
; 5. Multiply the two Hi dwords together,
392-
mov eax , [esp+ 8] ; Get Hi dword of Multiplier
393-
mul dword ptr [esp+16] ; Multiply by Hi dword of Multiplicand
392+
;mov eax , [esp+ 8] ; Get Hi dword of Multiplier
393+
mov eax , [esp+12]
394+
;mul dword ptr [esp+16] ; Multiply by Hi dword of Multiplicand
395+
mul dword ptr [esp+20]
394396
popfd ; Retrieve carry from above
395397
adc eax , ecx ; Add in partial product from above.
396398
adc edx , 0 ; Don't forget the carry!

0 commit comments

Comments
 (0)