• AVR Freaks

Hot!preprocessor arithmetic and linker

Author
Mark Yampolsky
Super Member
  • Total Posts : 122
  • Reward points : 0
  • Joined: 2009/04/03 18:50:36
  • Location: Russia Fryazino Moskow reg
  • Status: offline
2020/04/22 22:54:57 (permalink)
0

preprocessor arithmetic and linker

When using named constants in MPASM, arithmetic operations can be performed on them in the preprocessor. This allows you to make code readable.
However, due to the fact that the IVT of the IVController in PIC18FxxQ43 requires the address of the interrupt handler to be divided by 4, there is a difficulty with the syntax of the interrupt table.
Since the code label gets its value only by the linker, and the preprocessor calculates arithmetic even before the code is compiled, the syntax construct:
 dw Label_of_ISR>>2

leads to an error. At the same time, the design:
 dw Label_of_ISR

does not cause an error and compiles normally.

What is worth doing in this case?
The proposal to nail the handler through ORG is not considered. This will require constant manual maintenance of the value in ORG when modifying the code.
post edited by Mark Yampolsky - 2020/04/22 22:58:55
#1

1 Reply Related Threads

    1and0
    Access is Denied
    • Total Posts : 10985
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: preprocessor arithmetic and linker 2020/04/22 23:17:17 (permalink)
    5 (1)
    Mark Yampolsky
     
    The proposal to nail the handler through ORG is not considered. This will require constant manual maintenance of the value in ORG when modifying the code.

    That's an Achilles' heel of relocatable mode when it comes to the PIC18F Q43 and K42 vector table. For relocatable mode, use the CODE directive instead of ORG. Agree this will be a lot of maintenance, which actually is worse than using absolute mode where this is non-issue. LOL.
     
    post edited by 1and0 - 2020/04/22 23:38:35
    #2
    Jump to:
    © 2020 APG vNext Commercial Version 4.5