Tuesday, June 26, 2012

50. 16-BIT MULTIPLICATION IN 8086



16-BIT MULTIPLICATION FOR UNSIGNED NUMBERS


DATA SEGMENT
NUM DW 1234H,1234H
PROD DW 2 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA SI,NUM
MOV AX,[SI] 
MOV BX,[SI+2]

MUL BX 
MOV PROD,AX 
MOV PROD+2,DX
MOV AH,4CH
INT 21H
CODE ENDS
END START


INPUT: Multiplicand- 1234H,
       Multiplier-   1234H


OUTPUT: DX-01 4B
        AX-54 90




16-BIT MULTIPLICATION FOR SIGNED NUMBERS




DATA SEGMENT
NUM DW -2,1
PROD DW 2 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA SI,NUM 
MOV AX,[SI] 
MOV BX,[SI+2] 
IMUL BX 
MOV PROD,AX 
MOV PROD+2,DX
MOV AH,4CH
INT 21H
CODE ENDS
END START


INPUT: Multiplicand- -2,
       Multiplier-   1
OUTPUT: DX – FF FF
        AX – FF FE