Statement: Convert the HEX number in memory to its equivalent decimal number
    
               | Source program : 
 
LXI H, 4150 ; Point to dataLXI B, 0000 ; Initialize hundreds= 0, Tens=0MOV A, M ; Get hex data to ALOOP: SUI 64JC LOOP 1INR B ; hundreds= hundreds+1JMP LOOPLOOP 1: ADI 64 ; if subtracted extra, add it clear carry flagLOOP 2: SUI 0A  JC LOOP 3  INR C ; Tens=tens+1  JMP LOOP 2LOOP 3: ADI 0A ; If subtracted extra, add it againINX H ; A = UnitsMOV M, B ; store hundredsMOV B, A ; Combine Tens in C &MOV A, C ; Units in A to form aRLC ; Single 8-bit numberRLCRLCRLCADD B INX H MOV M, A ; Store tens & UnitsHLT | 
Note: In
 this experiment the number is converted to its equivalent decimal 
number using the following logic.  First count the number of hundreds, 
the number of tens & units present in that hex number.  Then add up 
to get the equivalent decimal number.  
Converting A9 we get:
          A9 /64=45 Hundreds = 01
          
Since 64(100 decimal) cannot be subtracted from 45 no. of hundreds = 01.  Now count tens 45/0A=3B Tens = 01 Now from 09, 0A cannot be subtracted.  Hence tens = 06 the decimal equivalent of A9 is 169.
 
 
0 Comments