Tuesday, March 22, 2016

8051 Division Unsigned 8-bit

Divide – DIV AB

DIV AB divides the unsigned eight-bit integer in the Accumulator by the unsigned eight-bit integer in register B. The Accumulator receives the integer part of the quotient; register B receives the integer remainder. The carry and OV flags are cleared.

Exception: if B had originally contained 00H, the values returned in the Accumulator and B-register are undefined and the overflow flag are set. The carry flag is cleared in any case.


The Accumulator contains 251 (0FBH or 11111011B) and B contains 18 ( 12H or 00010010B). The following instruction,


leaves 13 in the Accumulator (0DH or 00001101B) and the value 17 (11H or 00010001B) in B, since 251 = (13 x 18) + 17. Carry and OV are both cleared.

The 8051 supports byte over byte division.

DIV AB ; divide A by B

When dividing a byte by a byte, the numerator must be in register A and the denominator must be in B. After the DIV instruction is performed, the quotient is in A and the remainder is in B.

MOV A, #95H
MOV B, #10H
DIV AB ; A = 09, B= 05
END; end of asm source file

Note: If the denominator is 0 (B = 0), the OV flag is set to 1.

Related topics:
8051 Addition of Unsigned Numbers   |   8051 Addition of 16-bit Numbers   |   8051 Subtraction of Unsigned Numbers   |   8051 Subtraction of 16-bit Numbers   |   8051 Multiplication Unsigned 8-bit   |   8051 DIV Instruction

List of topics: 8051

No comments:

Post a Comment