??? 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 |