PDA

View Full Version : مشکل در کد ضرب اعداد بیشتر از 3 رقم



baranbahari1320
دوشنبه 26 تیر 1391, 10:36 صبح
من برای ضرب کردن اعداد بیشتر از 3 رقم دچار مشکل شدم من یه کدی هم نوشتم که میذارم ببینین کجاش ایراد داره.
compmul PROC NEAR

PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH BP
PUSH DI




MOV BP,0H


MOV CX,20
MOV sum,0H;


;conextmul:

MOV AX,0H;
MOV BX,0H;
MOV AX,WORD PTR ARRAY[BP]
MOV BX,WORD PTR ARRAY[BP+4]
push ax
;POP BX
;POP DX
;conextmul:
imul bx

add word ptr sum , ax

; BX, WORD PTR sum+2
adc word ptr sum+2,dx
;add word ptr k,ax

MOV AX,WORD PTR ARRAY[BP+2]
;mov bx,word ptr array[bp+2]
imul bx
add word ptr sum+2,ax
adc word ptr sum+4,dx
;adc word ptr sum+6,00
;add word ptr k,2

pop ax
;ADD BP,2
;mov ax,word ptr array[bp]
MOV BX,WORD PTR ARRAY[BP+6]
imul bx
adc word ptr sum+4,ax
adc word ptr sum+6,dx

mov ax,word ptr array[bp+2]
imul bx
adc word ptr sum+4,ax
adc word ptr sum+6,dx

;LOOP conextmul




POP DI
POP BP
POP SI
POP DX
POP CX
POP BX
POP AX

RET

compmul ENDP

;--------------------------------------

showmul PROC NEAR

PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH BP
PUSH DI



; mov bp,0h
MOV CX,0
CMP WORD PTR sum+2,0
JGE shmul

NOT WORD PTR sum
NOT WORD PTR sum+2
ADD WORD PTR sum,1
ADC WORD PTR sum+2,0000H
PUTCH '-'
shmul:

MOV DX,0
MOV BX,10
MOV ax,WORD PTR sum
DIV BX
MOV WORD PTR sum,ax
;add word ptr sum+2,dx
push dx
MOV Ax, WORD PTR sum
DIV BX
add WORD PTR sum+2,ax

;PUSH DX
INC CX

OR AX,WORD PTR sum
JNZ shmul

shdigit1: POP ax
ADD AL,30H
putch AL
LOOP shdigit1




POP DI
POP BP
POP SI
POP DX
POP CX
POP BX
POP AX

RET

showmul ENDP

قسمت محاسبه و نمایشش هست اگه لطف کنین منو راهنمایی کنین ممنون.