Reputation: 55
I'm working on an assignment in assembly 8086 and I get wrong answer; can anyone guess what is my problem? I want to multiply a word to byte.... here is my code:
STSEG SEGMENT
DB 64 DUP(?)
STSEG ENDS
;--------
DTSEG SEGMENT
D1 DW 6454H
D2 DB 44H
REPLY DW 2 DUP(?)
DTSEG ENDS
;--------
CDSEG SEGMENT
MAIN PROC FAR
ASSUME DS:DTSEG, SS:STSEG, CS:CDSEG
MOV AX,DTSEG
MOV DS,AX
MOV AX,0
MOV AL,D2
MOV BX,D1
MUL BL
MOV REPLY,AX
MOV REPLY+2,DX
MAIN ENDP
CDSEG ENDS
Upvotes: 1
Views: 1340
Reputation: 9899
As an alternative to Jose's answer and to show that
xor reg, reg
this:
xor ax, ax
mov al, D2
mul D1 <-- DX:AX = AX * D1
mov REPLY, ax
mov REPLY+2, dx
Upvotes: 1
Reputation: 10381
You have to multiply by BX
:
MOV AX,0
MOV AL,D2
MOV BX,D1
MUL BX ;◄■■ BX*AX = DX:AX.
MOV REPLY,AX
MOV REPLY+2,DX
Upvotes: 1