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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/12/08 13:42
Read: times


 
#157430 - All depends on language capabilities
Responding to: ???'s previous message
The following isn't exactly hard to do:
if (++digit0 >= 10) {
    digit0 = 0;
    if (++digit1 >= 10) {
        digit1 = 0;
        if (++digit2 >= 10) {
            ...
        }
    }
}

Easily modified to using an array and optionally to use a loop for the overflow, instead of nested if statements if code size is more important than speed.

Just avoid using a similar loop that the BIOS time keeping in the original PC did - it repeated while overflow, continuing into the variable after the end of the allocated 32-bit array :)

Rember that "more advanced" is not the same as "advanced" or "hard". It is just a relative comparison. More advanced than trivial can still be trivial.

But my comment wasn't about "more advanced" wasn't actually about updating the counter, but about splitting a 24-bit or 32-bit binary number into decimal again. Easy if using C with 32-bit support. sprintf() would do it trivially. With 32-bit integers, n%10 and n/=10 would also solve it quickly. But if the application is done in assembler on an 8-bit machine, then the user has to spend a bit of time, either implementing 24 bit divided by 8-bit or converting using successive shifts and adds.

List of 10 messages in thread
TopicAuthorDate
pulse counter with lcd            01/01/70 00:00      
   Re: pulse counter with lcd            01/01/70 00:00      
      5 memory locations?            01/01/70 00:00      
   Re: pulse counter with lcd            01/01/70 00:00      
      counting pules            01/01/70 00:00      
         Definitely use hardware if available            01/01/70 00:00      
            HUH?            01/01/70 00:00      
               All depends on language capabilities            01/01/70 00:00      
                  good idea...            01/01/70 00:00      
                     Bad choices            01/01/70 00:00      

Back to Subject List