Tuesday, September 29, 2026

Decimal to Hexadecimal conversion | 8085 Lab Program

 Section: Array Operations & Code Conversions

Aim: To convert a given decimal number to hexadecimal number.

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 decimal number with accumulator value.
  5. When both matches, the equivalent hexadecimal value is in B register.
  6. Store the resultant in memory location.

Program:

AddressLabelMnemonicsOperandComment
4100LXIH, 4200Initialize HL reg. to 4200H
4103MVIA, 00Initialize A register
4105MVIB, 00Initialize B register
4107LOOPINRBIncrement B reg.
4108ADI01Increment A reg
410ADAADecimal Adjust Accumulator
410BCMPMCompare M & A
410CJNZLOOPIf acc and given number are not equal, then go to LOOP
410FMOVA, BTransfer B reg to acc
4110STA4201Store the result in a memory location
4113HLTStop the program

Observation:

  • Input: Address 4200: 21
  • Output: Address 4201: 15

Result: Thus an ALP program for conversion of decimal to hexadecimal was written and executed.

Flowchart:

               +-------------------+
               |       START       |
               +---------+---------+
                         |
                         v
               +-------------------+
               |   [HL] <- 4200H   |
               +---------+---------+
                         |
                         v
               +-------------------+
               |    [A] <- 00H     |
               +---------+---------+
                         |
                         v
               +-------------------+
               |    [B] <- 00H     |
               +---------+---------+
                         |
                         v <------------------+
               +-------------------+          |
               |   [B] <- [B] + 1  |          |
               +---------+---------+          |
                         |                    |
                         v                    |
               +-------------------+          |
               |   [A] <- [A] + 1  |          |
               +---------+---------+          |
                         |                    |
                         v                    |
               +-------------------+          |
               |   Decimal Adjust  |          |
               |    Accumulator    |          |
               +---------+---------+          |
                         |                    |
                         v                    |
                       /   \                  |
                     /  Is   \                |
                   /   [A] =   \              |
                  <    [M]?     >             |
                   \           /              |
                     \       /                |
                       \   /                  |
                        |                     |
            +-----------+------------+        |
            |                        |        |
           YES                       NO       |
            |                        +--------+
            v
  +-------------------+
  |    [A] <- [B]     |
  +---------+---------+
            |
            v
  +-------------------+
  |     <- [A]  |
  +---------+---------+
            |
            v
  +-------------------+
  |       STOP        |
  +-------------------+

Viva Questions:

  1. What is meant by ADI instruction?
  2. What is the function of DAA instruction?
  3. What is the function of XCHG instruction?
  4. How you can load 16-bit data in 8500H and 8501H memory locations?
  5. What is the difference between LHLD and SHLD instructions?
  6. What is physical address?
  7. Define OFFSET address.


For all 2026 published articles list: click here: 

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