Hello again... this time i came with an optimisation idea, take it just as an idea... i don't know if it's possible or easy to do.
When doing "if" conditionals refered to a bit, for example this code:
if portb.6 = 0 then
Generates a large asm code not needed: _____________________________________________________
ENDIF10 clrf SysCalcTempA btfsc PORTB,6 incf SysCalcTempA,F clrf SysCalcTempB call SysCompEqual btfss SysCalcTempX,0 goto ENDIF11
SYSCOMPEQUAL clrf SYSCALCTEMPX movf SYSCALCTEMPA, W subwf SYSCALCTEMPB, W btfss STATUS, Z return movlw 255 movwf SYSCALCTEMPX return ____________________________________________________
When the needed code is just: ____________________________________________________
ENDIF10 btfsc PORTB,6 goto ENDIF11 ___________________________________________________
If could be an easy way to not add the syscompequal code when testing just bits. I think this could be a good optimisation...
What do you think?
What actually i do is just inline asm, for: if portb.6=0 then:
btfsc PORTB,6 goto my label ..... ..... .... mylabel:
Adn for: if portb.6=1 then:
btfss PORTB,6 goto my label ..... ..... .... mylabel:
I found that the optimization is done when i do this way:
if portb.6 off then
instead of: if portb.6 = 0 then
then i was doing the wrong way.... :)
Log in to post a comment.
Hello again... this time i came with an optimisation idea, take it just as an idea... i don't know if it's possible or easy to do.
When doing "if" conditionals refered to a bit, for example this code:
if portb.6 = 0 then
Generates a large asm code not needed:
_____________________________________________________
ENDIF10
clrf SysCalcTempA
btfsc PORTB,6
incf SysCalcTempA,F
clrf SysCalcTempB
call SysCompEqual
btfss SysCalcTempX,0
goto ENDIF11
SYSCOMPEQUAL
clrf SYSCALCTEMPX
movf SYSCALCTEMPA, W
subwf SYSCALCTEMPB, W
btfss STATUS, Z
return
movlw 255
movwf SYSCALCTEMPX
return
____________________________________________________
When the needed code is just:
____________________________________________________
ENDIF10
btfsc PORTB,6
goto ENDIF11
___________________________________________________
If could be an easy way to not add the syscompequal code when testing just bits.
I think this could be a good optimisation...
What do you think?
What actually i do is just inline asm, for: if portb.6=0 then:
btfsc PORTB,6
goto my label
.....
.....
....
mylabel:
Adn for: if portb.6=1 then:
btfss PORTB,6
goto my label
.....
.....
....
mylabel:
I found that the optimization is done when i do this way:
if portb.6 off then
instead of:
if portb.6 = 0 then
then i was doing the wrong way.... :)