DIVISION OF TWO 8 BIT NUMBERS

AIM:
     To perform the division of two 8 bit numbers using 8085.
     
ALGORITHM:
     1) Start the program by loading HL register pair with address of memory location.
     2) Move the data to a register(B register).
     3) Get the second data and load into Accumulator.
     4) Compare the two numbers to check for carry.
     5) Subtract the two numbers.
     6) Increment the value of carry .
     7) Check whether repeated subtraction is over and store the value of product and
        carry in memory location.
     8) Terminate the program.
     

PROGRAM:
               LXI  H, 4150
               MOV  B,M      Get the dividend in B – reg.
               MVI  C,00       Clear C – reg for qoutient
               INX  H
               MOV A,M       Get the divisor in A – reg.
NEXT:     CMP B             Compare A - reg with register B.
               JC  LOOP         Jump on carry to LOOP
               SUB  B             Subtract A – reg from B- reg.
               INR C               Increment content of register C.
               JMP NEXT      Jump to NEXT
 LOOP:    STA 4152         Store the remainder in Memory
               MOV A,C
               STA 4153         Store the quotient in memory
               HLT                  Terminate the program.

OBSERVATION:   

    Input:
F (4150)
FF (4251)
    Output:
01 (4152) ---- Remainder
    FE (4153) ---- Quotient
   
RESULT:
Thus the program to divide two 8-bit numbers was executed.

22 comments:

  1. It's very straightforward to find out any matter on web as compared to textbooks, as I found this piece of writing at this website.

    Take a look at my web page raspberry ketones

    ReplyDelete
  2. this program is executable but coments are not right.

    ReplyDelete
    Replies
    1. your are good at programming.............

      Delete
    2. This comment has been removed by the author.

      Delete
  3. hahaha what a dumbass programm check mine out more simple:

    LXI H 3000h
    MOV A M
    INX H
    MOV B M
    MVI C 00h
    L: SUB B
    INR C
    CMP B
    JNC L
    REMAINDER: STA 2051h
    MOV A C
    QUOTIENT: STA 2050h
    HLT

    ReplyDelete
    Replies
    1. store dividend at 3000h and divisor at 3001h rest is history hehe

      Delete
    2. its not correct.you are substracting before you comparing the numerator and denominator .

      Delete
    3. its not correct.you are substracting before you comparing the numerator and denominator .

      Delete
  4. good work , useful and innovative to find exp on web

    ReplyDelete
  5. logic problem,you're storing the divisor if carry flag is set but we need to store 0 when divisor is more than
    the
    dividend

    ReplyDelete
  6. There are critical mistakes in the program:
    1) CMP B is wrong because you comparing divisor with dividend, i.e., divisor-dividend so your logic fails
    2) use of JMP which makes the program run infinite time

    Actual Program:
    mvi D,00h
    lda 4150h
    mov B,A
    lda 4151h
    mov C,A
    cmp B
    jnc x
    mov A,B
    y: sub C
    inr D
    cmp C
    jnc y
    sta 4152
    mov A,D
    sta 4153
    hlt
    x: mov A,B
    sta 4152
    mov A,D
    sta 4153
    hlt

    ReplyDelete
    Replies
    1. after cmp B i think it should be JC X.(jump when there is carry)

      Delete
    2. yes.there we should not get carry when we are comparing.i.e we need the divident be greater than the divisor.so as per cmp condition carry should be 0 and hence using JC B will be appropriate.

      Delete
  7. This comment has been removed by the author.

    ReplyDelete
  8. If we talk about printers first name comes in our head is Brother Printers, for latest and updated Drivers for Brother go to the Following Sites.

    solutions.brother.com/windows
    solutions.brother.com/windows
    solutions.brother.com/windows
    solutions.brother.com/windows

    ReplyDelete