Division of Two 8 Bit Number

Sunny Bhaskar

11/6/20241 min read

Algorithm
  1. Load the dividend (04H) into the accumulator.

  2. Load the divisor (02H) into register B.

  3. Initialize register C to 00H to store the quotient.

  4. Perform the following in a loop until the value in the accumulator becomes less than B:

    • Subtract B from the accumulator.

    • Increment the quotient in C.

  5. After exiting the loop, the accumulator holds the remainder, and register C holds the quotient.

  6. Store the quotient in a specified memory location (e.g., 2053H) and the remainder in another memory location (e.g., 2054H).

  7. Halt the program.

Program

MVI A, 04H ; Load 04H into accumulator A (dividend)

MVI B, 02H ; Load 02H into register B (divisor)

MVI C, 00H ; Clear C to store the quotient

DIV_LOOP:

CMP B ; Compare A with B

JC DIV_DONE ; If A < B, jump to DIV_DONE

SUB B ; A = A - B

INR C ; Increment quotient

JMP DIV_LOOP ; Repeat loop

DIV_DONE:

STA 2053H ; Store the quotient (02H) at memory location 2053H

MOV D, A ; Move remainder to D

STA 2054H ; Store the remainder (00H) at memory location 2054H

HLT ; Halt the program

Address

Prayagraj Phaphamau

Contacts

7518998334
sunnygamingyt298@gmail.com

Subscribe to our newsletter