Thursday, June 28, 2012

61. 16-BIT DIVISION IN 8086


16-BIT DIVISION FOR SIGNED NUMBERS


DATA SEGMENT
NUM1 DW 4567H,2345H
NUM2 DW 4111H
QUO DW 2 DUP(0)
REM DW 1 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA

MOV DS,AX
MOV AX,NUM1 
MOV DX,NUM1+2
DIV NUM2
MOV QUO,AX
MOV REM,DX
MOV AH,4CH
INT 21H
CODE ENDS
END START


INPUT:     Dividend - 23454567,
           Divisor - 4111,
OUTPUT:    AX – 8AC5H (quotient);
           DX – 0952H (reminder);




16-BIT DIVISION FOR UNSIGNED NUMBERS



DATA SEGMENT
NUM1 DW 4567H,2345H
NUM2 DW 4111H
QUO DW 2 DUP(0)
REM DW 1 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV AX,NUM1 
MOV DX,NUM1+2
CWD
IDIV NUM2
MOV QUO,AX
MOV REM,DX
MOV AH,4CH
INT 21H
CODE ENDS
END START


INPUT:   Dividend - -44444444,
         Divisor - 2222,
0UTPUT:  AX – FE (quotient);
         DX – FF (reminder)