Menu

optimisation sugestion

Santiago
2009-01-27
2013-05-30
  • Santiago

    Santiago - 2009-01-27

    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?

     
    • Nobody/Anonymous

      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:

       
    • Santiago

      Santiago - 2009-02-01

      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.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.