We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I want to generate very efficient code using the carry-bit from C-code, and the instructions JNC or JC.
... sbit PinBit= P0^0; //port-IO bit ... CY=PinBit; //generates MOV C,PinBit ... if(CY) { //do something } IfNotCY: ...
The if(CY) instructiuons generates JNB CY,IfNotCY
How can i get it to use the more efficient JNC IfNotCY?
Analogously, if(!CY) should generate JC {label}.
"i have to scrutinize every clock cycle used."
You cannot ever guarantee that any particular 'C' source line will generate any specific sequence of machine instructions.
That's the whole point of a high-level language - you trade-off control of the generated code for (generally) increased programmer productivity.
Therefore, in any case where you must "scrutinize every clock cycle used", you just have to use assembler. There is no choice.
Thanks for the feedback. it works flawlessly in assembly, i was just trying to stick with C, to make readabillity and debugging easier.
"i was just trying to stick with C, to make readabillity and debugging easier."
Exactly - that's the (potential) programmer productivity gain from using a HLL.
But, when absolute timing control is critical, you have nothing to trade - you must stick with assembler.
But be sure to be extra careful in the documentation of your assembler - well documented, well structured assembler need not be hard to debug or maintain!