Section 14: Flags continue234
  3. Rewrite the timing program above so that it also counts the number of times the flag was cleared (unsuccessful timings). Again, store that number in a register for later reference.
  4. The example on page 220 converts single-digit hexadecimal numbers to their decimal equivalents. Using the following flowchart, and the concepts in the example problem, write a new program that converts two-digit hexadecimals to decimals. A solution to this problem is given following the flowchart. Before looking at the solution, try writing your own program from the flowchart.
    Run the program and convert 4F, 2B, 13, AA to decimal equivalents. The program prompts you for one digit of the number at a time (e.g., to convert 4F, when the program prompts you, first key in 4 R/S , then ALPHA F ALPHA R/S ).
    (Answers: 79; 43; 19; 170).
                       
Start
                                       
                                               
         
  Store A-F into R10-R15  
                         
                                               
         
  Clear flags 22 & 23  
                         
                                               
         
  Store 0 in input counter  
                         
 
                                           
       
  Prompt for input  
                       
                                           
          Yes
Was input
a number?
Yes                          
            Yes                    
                      No
Is this
second input?
No          
          No
Was input
an ALPHA?
No              
                       
                      Yes Yes  
  Multiply number by
10, store in R03
 
   
              Yes Yes                  
         
  Store ALPHA into X  
                 
                               
  Clear flags
22 & 23
 
   
         
  Store loop control
number into R02
(10.01501)
 
             
                           
       
  Using loop control
number as register address,
recall ALPHA stored in
indirectly addressed register
 
                     
                             
           
  Add to
number
in R03
 
             
                                     
Is
input ALPHA same
as stored in ALPHA?
 
  Increment R02 by 1,
stop if greater
than 15 (Use ISG )
 
  No No                      
       
  Display
result
 
             
    No                    
              Yes Yes                          
         
  Recall integer portion
of loop control number
(Same as decimal equivalent
of ALPHA stored in that register)
 
   
Stop