Thursday, June 28, 2012

60. 8-BIT DIVISION IN 8086


8-BIT DIVISION FOR UNSIGNED NUMBERS


DATA SEGMENT
NUM1 DB 72H,
NUM2 DB 02H
QUO DB 1 DUP(0)
REM DB 1 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV AL,NUM1 

MOV AH,0H
DIV NUM2
MOV QUO,AL
MOV REM,AH 
MOV AH,4CH
INT 21H
CODE ENDS
END START


INPUT:        Dividend - 72H,
                    Divisor - 02 H,
0UTPUT:     AL - 39H (quotient);
                    AX - 00H (reminder);


INPUT:       Dividend - 55H,
                   Divisor - 04 H,
0UTPUT:    AL - 15H (quotient);
                   AX - 01H (reminder);




8-BIT DIVISION FOR SIGNED NUMBERS



DATA SEGMENT
NUM1 DB -10
NUM2 DB 02
QUO DB 1 DUP(0)
REM DB 1 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV AL,NUM1 
CBW
IDIV NUM2 
MOV QUO,AL 
MOV REM,AH 
MOV AH,4CH
INT 21H
CODE ENDS
END START




INPUT:   Dividend - -10
         Divisor - 03
0UTPUT:  AL – FDH (quotient);
         AX – FF H (reminder) ; Result is in two complement form