启动:
MOV AX,0012h
MOV BX,0000h
MOV CX,0033h
MOV DX,0000h
MOV [100h],AX
MOV [102h],BX
MOV [104h],CX
MOV [106h],DX
MOV SI,40h
tekrar:
MOV DI,AX ;sonucu indeks kaydeder
AND DI,01h
XOR DI,01h
JZ topla_kaydir
devam:
RCR DX,1
RCR CX,1
RCR BX,1
RCR AX,1
SHR [100h],1
SHR [102h],1
DEC SI
CMP SI,0
JNZ tekrar
JMP son
topla_kaydir:
ADD DX,[104h]
ADC CX,[104h]
JMP devam
这是我的代码的一部分。我想在不使用mul
操作和扩展寄存器的情况下将两个32位数相乘。我无法得到正确的结果。
答案 0 :(得分:2)
MOV DI,AX ;sonucu indeks kaydeder AND DI,01h XOR DI,01h JZ topla_kaydir
This code jumps if the lowest bit of AX is set to the label topla_kaydir
Simply write:
test ax,1
jnz topla_kaydir
topla_kaydir: ADD DX,[104h] ADC CX,[104h]
You setup with CX being the low word and DX being the high word. This addition needs to respect that order.
If the intention is to raise the 32 bit value in DX:CX then you should have written:
add cx,[104h]
adc dx,[106h]
SHR [100h],1 SHR [102h],1
There's not much point in these SHR
's. The value they produce isn't used anywhere!
What you need is doubling the value of one of the numbers (the one that you add to the result when you find a set bit).
shl [104h],1
rcl [106h],1
MOV SI,40h
Don't iterate 64 times when your source has only 32 bits! It's meaningless.
mov si,32