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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/08/07 15:11
Read: times


 
#130428 - :-)
Responding to: ???'s previous message
Erik Malund said:
Jan, you LOVE assembler and HATE C. So, when C requires that you do something you (hopefully) have always done in assembler, it should make you feel right at home.

I don't intend to use C regularly so I don't care from a user standpoint.

But it's fun to think about the ways how to improve these things.

Btw. the question arose from a "quiz" which appeared in a local e-mail hw forum: guess the "result" (after the program running long enough).

int    counter = -22;
int    result = 1;

void timer0handler( void ) interrupt 1 {
       counter --;
       if (counter == -20 )
          counter = 0;
       if (counter == -5 )
          counter -= 10;
       if (counter <-40 )
          counter = 0;
}

void main( void ) {
      Init_Timer;			// timer 1000x/s

      while (1) {
        if (counter == -10)
           result = 5;             // A
        if (counter == -30)
           result = 10;            // B
        if ((counter-result)>0)
           result = 100;           // C
        if ((counter-result)<-400)
           result = 100;       }   // C
  }

JW


List of 32 messages in thread
TopicAuthorDate
atomicity, multibyte variables, C and my comfort            01/01/70 00:00      
   No way            01/01/70 00:00      
      Well, theoretically ...            01/01/70 00:00      
   Yes sdcc at least            01/01/70 00:00      
      Keil            01/01/70 00:00      
   Does it matter?            01/01/70 00:00      
      sort of...            01/01/70 00:00      
         Lack of this feature ...            01/01/70 00:00      
            really?            01/01/70 00:00      
   talking out of both sides of the mouth            01/01/70 00:00      
      :-)            01/01/70 00:00      
         the simple solution            01/01/70 00:00      
            The question was not how to fix it...            01/01/70 00:00      
   Don't disable            01/01/70 00:00      
      C extensions            01/01/70 00:00      
         ring buffer, atomicity and C            01/01/70 00:00      
            OK that was a stupid example...            01/01/70 00:00      
      Hardware solution called for            01/01/70 00:00      
         isn't HLL supposed to hide the low level details?            01/01/70 00:00      
            the skinny            01/01/70 00:00      
               Word length & Atomicity            01/01/70 00:00      
            Side effects            01/01/70 00:00      
               questions and answers            01/01/70 00:00      
                  Embedded Specific            01/01/70 00:00      
                     Neil, you GOT it            01/01/70 00:00      
                        waitaminute...            01/01/70 00:00      
                           from an old hand to a newbie            01/01/70 00:00      
                              what helps is good (?)            01/01/70 00:00      
                                 The warning you propose would be 'wrong' in some c            01/01/70 00:00      
                                    wrong warnings            01/01/70 00:00      
                                       Read-Modify-Write            01/01/70 00:00      
                                          OK then not simple            01/01/70 00:00      

Back to Subject List