This code:
//#define WORKS
#ifdef WORKS
if (PORTC.RC6 == 1)
LATC.RC3 = 1;
else
LATC.RC3 = 0;
#else
LATC.RC3 = (PORTC.RC6 == 1)?1:0;
#endif
Compiles to this with WORKS defined:
;TapShifter.c,135 :: if (PORTC.RC6 == 1)
0x06FC 0xAC82 BTFSS PORTC, 6
0x06FE 0xD002 BRA L_main12
;TapShifter.c,136 :: LATC.RC3 = 1;
0x0700 0x868B BSF LATC, 3
0x0702 0xD001 BRA L_main13
L_main12:
;TapShifter.c,138 :: LATC.RC3 = 0;
0x0704 0x968B BCF LATC, 3
L_main13
Or this without, which works but is much less efficient, when the whole point of the ? operator is to be more efficient:
;TapShifter.c,140 :: LATC.RC3 = (PORTC.RC6 == 1)?1:0;
0x06FC 0xAC82 BTFSS PORTC, 6
0x06FE 0xD003 BRA L_main12
0x0700 0x0E01 MOVLW 1
0x0702 0x6E1C MOVWF ?FLOC___mainT142
0x0704 0xD001 BRA L_main13
L_main12:
0x0706 0x6A1C CLRF ?FLOC___mainT142
L_main13:
0x0708 0xB01C BTFSC ?FLOC___mainT142, 0
0x070A 0xD002 BRA L__main41
0x070C 0x968B BCF LATC, 3
0x070E 0xD001 BRA L__main42
L__main41:
0x0710 0x868B BSF LATC, 3
L__main42:
If it matters, this with with optimization set to zero.
Ira
compiler issue in 7.2.0
Re: compiler issue in 7.2.0
Hi,
This sounds strange, we will definitely check this out.
Thank you for your input.
Regards,
Filip.
This sounds strange, we will definitely check this out.
Thank you for your input.
Regards,
Filip.
Re: compiler issue in 7.2.0
I had mayor issues with a CCP module not wanting to go in the interrupt. Code worked on Proteus and had to reinstall MikroC and the suite to get it going again.... costed me many hours.
Re: compiler issue in 7.2.0
Here is another one:
;CutoutMain.c,46 :: OPTION_REG.TMR0CS = 1; //TIMER_0_START; // start timer to force cutout to the state chosen by INITIAL_STATE_PIN
0x001F 0x0021 MOVLB 1
0x0020 0x1695 BSF OPTION_REG, 5
What is the point of the line which says, "MOVLB 1"?
The next line is "MOVLB 0" so it really makes no sense. Just a waste of an instruction.
Ira
;CutoutMain.c,46 :: OPTION_REG.TMR0CS = 1; //TIMER_0_START; // start timer to force cutout to the state chosen by INITIAL_STATE_PIN
0x001F 0x0021 MOVLB 1
0x0020 0x1695 BSF OPTION_REG, 5
What is the point of the line which says, "MOVLB 1"?
The next line is "MOVLB 0" so it really makes no sense. Just a waste of an instruction.
Ira
Re: compiler issue in 7.2.0
And another one? What is the difference between these 2 pieces of code, should they not generate the same code?
Code: Select all
;CutoutMain.c,59 :: if (keypressed == (20+2)){//(KEY_PRESS_TIME + 2)){
0x002B 0x3000 MOVLW 0
0x002C 0x3A00 XORLW 0
0x002D 0x1D03 BTFSS STATUS, 2
0x002E 0x2831 GOTO L__main18
0x002F 0x3016 MOVLW 22
0x0030 0x0622 XORWF main_keypressed_L0, 0
L__main18:
0x0031 0x1D03 BTFSS STATUS, 2
0x0032 0x2838 GOTO L_main8
Code: Select all
;CutoutMain.c,59 :: if (keypressed == 22){//(KEY_PRESS_TIME + 2)){
0x002B 0x0822 MOVF main_keypressed_L0, 0
0x002C 0x3A16 XORLW 22
0x002D 0x1D03 BTFSS STATUS, 2
0x002E 0x2834 GOTO L_main8
Re: compiler issue in 7.2.0
And why is this code efficient:
And this code which should use BTFSC takes twice as many instruction cycles because it uses BTFSS?
Ira
Code: Select all
;CutoutMain.c,68 :: if (INTCON.TMR0IF == 1){
0x003B 0x1D0B BTFSS INTCON, 2
0x003C 0x283F GOTO L_main9
Code: Select all
;CutoutMain.c,77 :: if (state == 0){
0x0044 0x0823 MOVF main_state_L0, 0
0x0045 0x3A00 XORLW 0
0x0046 0x1D03 BTFSS STATUS, 2
0x0047 0x284B GOTO L_main11