Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/07/03 05:54
Read: times


 
#40990 - RE: any one has better option
Responding to: ???'s previous message
In your description at the top you have P1 as the input but in MAIN: you are using P0 as the input. Probably just an oversight, right?
You have defined the bit pattern wrong for eight, should be 7Fh, you have 8Fh. Also you failed to define bit pattern for nine (67h or 6Fh).
You can greatly reduce the amount of program space by using a simple lookup table (trust me, interrupts and lookup tables are not evil demons, they are very easy to use and require much less code.) At the end of your program add the line;
lookup: DB 3Fh,06h,5Bh,4Fh,66h,6Dh,7Dh,07h,7fh,67h
Initialize DPTR with the lookup address;
MOV DPTR,#lookup
Now, in the display portion of your code put the MSB value in A and ANL with 0Fh;
ANL A,#0Fh ; insure left nibble is 0
Now use the magical look up function;
MOVC A,@A+DPTR ; retrieve bit pattern
and viola!, A now holds the bit pattern for whatever BCD value was in A before. Move A to P2 and repeat the process for your LSB figure. Since in your MAIN: the MSB is in A and LSB in B. Your code would be;
DISPLAY:
MOV DPTR,#lookup
ANL A,#0Fh
MOVC A,@A+DPTR
MOV P2,A
MOV A,B
ANL A,#0Fh
MOVC A,@A+DPTR
MOV P3,A
(return to monitoring P1)
I just used 9 lines to display the binary number received at P1. Undoubtedly there will be others that can cut this down even further, but I wanted to keep it simple.

Hal



List of 12 messages in thread
TopicAuthorDate
any one has better option            01/01/70 00:00      
   RE: any one has better option            01/01/70 00:00      
   RE: still the same ...            01/01/70 00:00      
   RE: any one has better option            01/01/70 00:00      
   RE: any one has better option            01/01/70 00:00      
   RE: any one has better option            01/01/70 00:00      
   RE: any one has better option            01/01/70 00:00      
      RE: any one has better option            01/01/70 00:00      
         RE: any one has better option            01/01/70 00:00      
         RE: any one has better option            01/01/70 00:00      
            i think i got it...            01/01/70 00:00      
   RE: any one has better option            01/01/70 00:00      

Back to Subject List