gnupic: Re: [gnupic] label addresses and relocatable code


Previous by date: 29 Nov 2007 15:56:04 +0000 label addresses and relocatable code, James A. Cleland
Next by date: 29 Nov 2007 15:56:04 +0000 gputils portable ?, web domain
Previous in thread:
Next in thread:

Subject: Re: [gnupic] label addresses and relocatable code
From: "David Barnett" ####@####.####
Date: 29 Nov 2007 15:56:04 +0000
Message-Id: <4d52f78b0711290755y1d689464o1e1051285e46fb6@mail.gmail.com>

On Nov 29, 2007 1:16 AM, James A. Cleland ####@####.#### wrote:

> I don't see this documented anywhere, although I'm sure I've passed right
> over it. Anyway, sorry for the silly question.
>
> How does gpasm (or MPASM, for that matter) handle address calculations on
> labels when the code is assembled as a relocatable object file (for
> instance, if you wanted to calculate PCLATH bits for an out-of-page call
> or
> goto)?

gplink will only relocate the relocatable symbol and a constant offset, so
gpasm only allows relocatable symbols in that form, and they are only
allowed in instructions and directives that emit code that can be relocated.
As you suspected, that throws out some of the fancy (but often ugly, IMO)
calculations the assembler itself can do before generating code. When this
is a problem, it usually means you need to delay some processing until
runtime, which can be a huge pain but usually isn't bad. For instance, this:
  movlw (reloc_addr & 0x1F)
might become this:
  movlw reloc_addr
  andlw 0x1F
For jump tables, look into the pageselw directive, which overwrites WREG but
loads *all* of the PCLATH bits (usually amounts to movlw addr, movwf
PCLATH).

David Barnett

Previous by date: 29 Nov 2007 15:56:04 +0000 label addresses and relocatable code, James A. Cleland
Next by date: 29 Nov 2007 15:56:04 +0000 gputils portable ?, web domain
Previous in thread:
Next in thread:


Powered by ezmlm-browse 0.20.