??? 04/15/07 15:16 Read: times |
#137288 - Test Seems To Work Responding to: ???'s previous message |
I put the code you posted into a small Keil project file, albeit with a few more essential lines:
#include <c8051f020.h> // SFR declarations void main(void) { float a; a=5.34; if(a>1.2) P1=20; else P1=10; while(1); } I found it to compile just fine. In addition I stepped the code through the Keil simulation mode debugger and the P1=20; clause of the if/else was executed just like one would expect. BTW. Floating point on MCUs can sometimes be a bad idea. Note that this small program compiled to a whopping 167 bytes. For sure a small portion of the code was the C-Startup code but the main code lines are only a few bytes (43 to be exact) with a huge portion (109 bytes) taken up by the C?FPCMP3 routine which is used to compare variable a to 1.2. Michael Karas |
Topic | Author | Date |
if else statements in keil c51 | 01/01/70 00:00 | |
Things to check | 01/01/70 00:00 | |
example | 01/01/70 00:00 | |
And it might help to use hex | 01/01/70 00:00 | |
floating point | 01/01/70 00:00 | |
Not true | 01/01/70 00:00 | |
further... | 01/01/70 00:00 | |
I suggest you read this.. | 01/01/70 00:00 | |
Test Seems To Work | 01/01/70 00:00 | |
SDCC version works also | 01/01/70 00:00 | |
Testing the typo...![]() | 01/01/70 00:00 | |
its a lot easier to use fixed point | 01/01/70 00:00 |