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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/02/08 16:24
Read: times


 
#159541 - Trivial solution: compare/subtract
Responding to: ???'s previous message
What is "not found"?

You tried the DA instruction?

Short info about this instruction says:
http://www.hobbyprojects.com/8051_tuto...djust.html
Description: DA adjusts the contents of the Accumulator to correspond to a BCD (Binary Coded Decimal) number after two BCD numbers have been added by the ADD or ADDC instruction. If the carry bit is set or if the value of bits 0-3 exceed 9, 0x06 is added to the accumulator. If the carry bit was set when the instruction began, or if 0x06 was added to the accumulator in the first step, 0x60 is added to the accumulator.

Your value 240 (0xf0) is not the result of the addition of two BCD numbers with the ADD or ADDC instructions.

The example code available on this forum shows how to divide in assembler. But you may also use a trivial compare/subtract loop.
- Set val_times_100 to zero.
- Set val_times_10 to zero.
- Set val_times_1 to zero.
- While input value is larger than 99:
  - increment val_times_100
  - subtract 100 from input value
- While input value is larger than 9:
  - increment val_times_10
  - subtract 10 from input value
- Store remainder of input value in val_times_1
Now you have splitted a binary value 0..255 into three variables, all containing a value between 0 and 9. Each of the variables val_times_100, val_times_10 and val_times_1 can now be assigned to one 7447 to drive one 7-segment digit.



List of 27 messages in thread
TopicAuthorDate
tachometer            01/01/70 00:00      
   schematic, please            01/01/70 00:00      
      Datasheet?            01/01/70 00:00      
      reply to tachometer            01/01/70 00:00      
         Resistor to processor too.            01/01/70 00:00      
            the schematic is            01/01/70 00:00      
               Limitation of base current to 2N2222?            01/01/70 00:00      
               in effect            01/01/70 00:00      
   another option            01/01/70 00:00      
      What is your part in this assignment?            01/01/70 00:00      
   thanks            01/01/70 00:00      
      Don't panic            01/01/70 00:00      
      RE: dont have enough knowledge on microcontrollers            01/01/70 00:00      
   CODE            01/01/70 00:00      
   expecting a reply now            01/01/70 00:00      
      Not BCD!            01/01/70 00:00      
         how to solve?            01/01/70 00:00      
            your task            01/01/70 00:00      
               trying!!            01/01/70 00:00      
   not found !!!!            01/01/70 00:00      
      Trivial solution: compare/subtract            01/01/70 00:00      
         thanks a lot!!!            01/01/70 00:00      
            google or paper and pen            01/01/70 00:00      
   something weird            01/01/70 00:00      
      treading dangerous waters            01/01/70 00:00      
      Nothing weird            01/01/70 00:00      

Back to Subject List