10-digit multiplication using arrays

Started by shagywashere, November 30, 2011, 01:42:11 AM

Previous topic - Next topic

shagywashere

Using three arrays, have to multiply two 10-digit numbers. I figured out how to put the 10-digits into the array, but I'm having trouble multiplying it. We store the result in the third array. I posted my multiplication procedure, anyone help me out? It just freezes when the cmd prompt when I run it, and I have to restart the prompt to run it again.


.DATA
ARR1 DB 20 DUP (0)
ARR2 DB 20 DUP (0)
ARR3 DB 20 DUP (0)



MULTIPLY PROC NEAR
MOV             CX, 10
MOV DI, 9
.REPEAT
MOV AL, ARR1[DI]
MOV BL, ARR2[DI]
IMUL             BX
.IF AL >= 10
MOV BX, 10
IDIV             BX
MOV REM, AL
.ENDIF
MOV ARR3[DI], DL
MOV BL, REM
ADD ARR3[DI], BL
DEC DI
.UNTILCXZ

MULTIPLY ENDP

raymond

Have a look at the following. It contains many examples (including multiplications) using Binary Coded Decimals, i.e. BCD.
http://www.ray.masmcode.com/BCDtut.html

You may find it a lot easier by using the BCD instructions. They work the same for 16-bit and 32-bit apps.
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

clive

The routine doesn't have a RET at the end, and CX is never decremented.
It could be a random act of randomness. Those happen a lot as well.

shagywashere

CX is decremented automatically using the ".UNTILCXZ" command. But yea no RET must have been what was making it freeze. Thanks.

clive

Sorry, I don't use the high level constructs and couldn't find a quick cite, but yes it appear to assemble to a LOOP rather than JCXZ.
It could be a random act of randomness. Those happen a lot as well.