Announcement

Collapse
No announcement yet.

Pic memeory code space overheads for bit varables

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pic memeory code space overheads for bit varables

    hI CHARLES


    i have a lot of code which has defined a byte with sub bit variable names



    i am desperate for more code space , is there any code space advantage by not defining each bit variable , and just addressing each byte.0 directly

    cheers

    Sheldon

  • #2
    Sheldon, I usually write my bit variables like this:

    '******************** 'VARIABLES USED FOR CLOCK *********************
    TIMEBITS VAR WORD BANK0
    ROLLOVER VAR TIMEBITS.0 '1 SECOND TIMING FLAG
    TX_EMPTY VAR TIMEBITS.1 'TRANSMIT BUFFER EMPTY FLAG
    PARITYTYPE VAR TIMEBITS.2 'PARITY TYPE (1=ODD/0=EVEN)
    RX_BUFFULL VAR TIMEBITS.3 'RECEIVER BUFFER FULL FLAG
    CLEARINPT VAR TIMEBITS.4 'CLEAR INPUT BUFFER FLAG
    COWSCOMHOME VAR TIMEBITS.5 'LOOP FLAG
    RX_MESSAGE VAR TIMEBITS.6 'MESSAGE AVAILABLE FLAG
    PATDOG VAR TIMEBITS.7 'WATCHDOG FLAG (BONE)
    ONETICK VAR TIMEBITS.8 '10 MILLISECOND A/D PACING FLAG
    TENTICK VAR TIMEBITS.9 '100 MILLISECOND PACING FLAG
    SECTICK VAR TIMEBITS.10 '1 SECOND PACING FLAG
    LZB VAR TIMEBITS.11 'LEAST SIGNIFICANT BIT FLAG
    DISPFLAG VAR TIMEBITS.12 '1 SECOND ANALOG DISPLAY UPDATE FLAG
    PASSENABLE VAR TIMEBITS.13 'PASSWORD ENABLE FLAG
    QUE VAR TIMEBITS.14
    FIVETENTICK VAR TIMEBITS.15
    Dave Purola,
    N8NTA
    EN82fn

    Comment


    • #3
      You're asking about Code Space, correct? Not RAM where the variables reside.

      The biggest effect that variables have on code space relates to the bank where they are located. If PBP doesn't have to change banks to access a variable, it saves one location of code space for the operation. I've worked on some code in the past where I experimented with BANK modifiers when declaring variables in order to reduce code space usage. The results were there, but I don't know if I would call them significant. This happened before the code space was increased on newer PICs, so the concern has diminished.

      I would guess there are other techniques that would yield much more savings than variable manipulation.

      In answer to your specific question about a bit-alias vs a byte.bit name, they are the same. Aliases in PBP are just text substitutions. They don't affect the compiled code.

      Charles Leo
      ME Labs, Inc.
      http://melabs.com

      Comment


      • #4
        ok thanks , yes i thought there be little to be gained in just changing this item ,

        Comment

        Working...
        X