13 Mar 2013

Progrraming for Subtraction of two 8 bit numbers using 8085

As mention on previous blog for getting subtraction of two 8 bit number the algorithm is given bellow

             For 8 bit Subtraction we need

  •    Start the program by loading the first data into Accumulator.
  •     Move the data to a register (B register).
  •     Get the second data and load into Accumulator.
  •     sub the two register contents.
  •     Check for carry.
  •     Store the value of sum and carry in memory location.
  •     Terminate the program.

             Program                                              Comment

             MVI C,00                                     Initialize C register to 00                                       

             LDA 4150                                    Load the value to Accumulator.

             MOV B, A                                    Move the content of Accumulator to B register.

             LDA 4151                                    Load the value to Accumulator.

             SUB B                                          Subtract  the value of register B to A

             JNC                                              LOOP Jump on no carry

             INR C                                           Increment value of register C

LOOP: STA 4152                                    Store the value of Accumulator (SUM).

             MOV A, C                                    Move content of register C to Acc.

             STA 4153                                     Store the value of Accumulator (CARRY)

             HLT                                              Halt the program.

No comments:

Post a Comment