Wednesday, September 30, 2026

Hexadecimal to Decimal conversion | 8085 Lab Program

 Section: Array Operations & Code Conversions

Aim: To convert a given hexadecimal number to decimal number and also to verify the result.

Apparatus Required: 8085 microprocessor kit, key board.

Algorithm:

  1. Initialize the memory location to the data pointer.
  2. Increment B register.
  3. Increment accumulator by 1 and adjust it to decimal every time.
  4. Compare the given hexadecimal number with B register value.
  5. When both match, the equivalent decimal value is in A register.
  6. Store the resultant in memory location.

Program:

AddressLabelMnemonicsOperandComment
4100LXIH, 4200Initialize HL reg. to 4200H
4103MVIA, 00Initialize A register
4105MVIB, 00Initialize B register
4107MVIC, 00Initialize C register for carry
4109LOOPINRBIncrement B reg
410AADI01Increment A reg
410CDAADecimal Adjust Accumulator
410DJNCNEXTIf there is no carry go to NEXT
4110INRCIncrement C register
4111NEXTMOVD, ATransfer A to D
4112MOVA, BTransfer B to A
4113CMPMCompare M & A
4114MOVA, DTransfer D to A
4115JNZLOOPIf acc and given number are not equal, then go to LOOP
4118STA4201Store the result in a memory location
411BMOVA, CTransfer C to A
411CSTA4202Store the carry in another memory location
411FHLTStop the program

Observation:

  • Input:
    • Address 4200: D5
  • Output:
    • Address 4201: 13
    • Address 4202: 02

Result: Thus an ALP program for conversion of hexadecimal to decimal was executed and the result is verified.

Flowchart:

               +-------------------+
               |       START       |
               +---------+---------+
                         |
                         v
               +-------------------+
               |   [HL] <- 4200H   |
               +---------+---------+
                         |
                         v
               +-------------------+
               |    [A] <- 00H     |
               +---------+---------+
                         |
                         v
               +-------------------+
               |    [B] <- 00H     |
               +---------+---------+
                         |
                         v
               +-------------------+
               |    [C] <- 00H     |
               +---------+---------+
                         |
                         v <------------------+
               +-------------------+          |
               |   [B] <- [B] + 1  |          |
               +---------+---------+          |
                         |                    |
                         v                    |
               +-------------------+          |
               |   [A] <- [A] + 1  |          |
               +---------+---------+          |
                         |                    |
                         v                    |
               +-------------------+          |
               |   Decimal Adjust  |          |
               |    Accumulator    |          |
               +---------+---------+          |
                         |                    |
                         v                    |
                       /   \                  |
                     /  Is   \                |
                   /  there a  \              |
                  <   Carry?   >              |
                   \  (CY = 1) /              |
                     \      /                 |
                       \  /                   |
                        |                     |
            +-----------+-----------+         |
            |                       |         |
           YES                      NO        |
            |                       |         |
            v                       |         |
  +-------------------+             |         |
  |   [C] <- [C] + 1  |             |         |
  +---------+---------+             |         |
            |                       |         |
            +-----------+-----------+         |
                        |                     |
                        v                     |
              +-------------------+           |
              |    [D] <- [A]     |           |
              |    [A] <- [B]     |           |
              +---------+---------+           |
                        |                     |
                        v                     |
                      /   \                   |
                    /  Is   \                 |
                  /   [A] =   \               |
                 <    [M]?     >              |
                  \           /               |
                    \       /                 |
                      \   /                   |
                       |                      |
           +-----------+------------+         |
           |                        |         |
          YES                       NO        |
           |                        +---------+
           v
 +-------------------+
 |    <- [A]         |
 |    [A] <- [C]     |
 |    <- [A]         |
 +---------+---------+
           |
           v
 +-------------------+
 |       STOP        |
 +-------------------+

Viva Questions:

  1. What is meant by instruction DAA?
  2. Why data bus is bi-directional?
  3. Specifies the function of address bus and the direction of address bus?
  4. How many memory location can be addressed by a microprocessor with the 14 address lines?
  5. List various instructions that can be used to clear accumulator in 8085?
  6. When the Ready signal of 8085 is sampled by the processor?
  7. List out the similarities b/w the CALL_RET and PUSH_POP instructions?


For all 2026 published articles list: click here: 

…till the next post, bye-bye & take care