Menu

EQU value of literal

Help
MBB
2012-09-07
2013-05-30
  • MBB

    MBB - 2012-09-07

    I'm using a PIC 16F876.

    The data sheet says the CALL command in binary format is 10 0kkk kkkk kkkk. ( k = literal).

    With eleven k entries the largest binary number would be 111 1111 1111 which in Decimal is 2047.

    When I look at some of my EQU values I see some that are greater than 2047.

    For example:
    CLS EQU 2048
    D10US_START EQU 2070
    DELAY_10US EQU 2070
    DELAYUS0 EQU 2072
    DELAY_MS EQU 2078
    DMS_START EQU 2079
    DMS_OUTER EQU 2081
    DMS_INNER EQU 2083
    DELAY_S EQU 2092
    DS_START EQU 2092
    FN_LCDREADY EQU 2100
    ENDIF41 EQU 2122
    LOCATE EQU 2130
    ENDIF22 EQU 2139
    PRINT54 EQU 2158
    SYSFORLOOP1 EQU 2170
    SYSCOMPEQUAL EQU 2189
    SYSCOMPEQUAL16 EQU 2195
    SYSCOMPLESSTHAN16 EQU 2206
    SCLT16TRUE EQU 2219
    SYSDIVSUB16 EQU 2221
    ENDIF39 EQU 2243
    SYSDIV16START EQU 2245
    ENDIF40 EQU 2266
    SYSMULTSUB EQU 2277
    MUL8LOOP EQU 2278
    SYSMULTSUB16 EQU 2289
    MUL16LOOP EQU 2299
    ENDIF37 EQU 2307
    SYSREADSTRING EQU 2327
    SYSREADSTRINGPART EQU 2337
    SYSSTRINGREADCHECK EQU 2346
    SYSSTRINGREAD EQU 2349
    SYSSTRINGTABLES EQU 2355
    STRINGTABLE1 EQU 2362
    STRINGTABLE2 EQU 2378
    STRINGTABLE3 EQU 2384
    STRINGTABLE4 EQU 2390
    STRINGTABLE5 EQU 2394
    STRINGTABLE6 EQU 2399
    TIME_CALC EQU 2414
    TIME_CALC EQU 2414

    Is it possible for these EQU values to be greater than 2047?

     
  • Hugh Considine

    Hugh Considine - 2012-09-08

    Yes, that's normal if you have a program larger than 1 page.

    GOTO and CALL can only accept 11 bits, which is where the page size of 2048 words comes from. If a bigger number is put in to one, the high bits will be ignored. They need to be dealt with using a PAGESEL command.

    Some of those constants, like the STRINGTABLE ones, are dealt with by modifying the program counter directly. The 6 high bits are copied into the PCLATH register, then the 8 lower bits go into PCL. That sets the entire 14 bit program counter.

     
  • MBB

    MBB - 2012-09-09

    Thanks!  That was very helpful.

     

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.