gnupic: [PATCH] Bad warning for BRA on 16F code
Subject:
RE: [PATCH] Bad warning for BRA on 16F code
From:
mengjin su ####@####.####
Date:
22 Jul 2013 16:55:04 -0000
Message-Id: <BLU168-W1280CDE969CF044AD6082E3D06E0@phx.gbl>
In Hex output, PIC always uses byte address.
In assembly language, those trivial things happen all the time.
> From: ####@####.####
> To: ####@####.####
> Subject: [PATCH] Bad warning for BRA on 16F code
> Date: Sun, 21 Jul 2013 22:05:03 -0600
>
> I have found a warning that I believe is wrong. I am assembling for 16f1508 and I am
> getting a warning for a branch to a label with an odd address. Here is the test code:
>
> > cat bad.asm
> LIST P=PIC16F1518
> include p16f1518.inc
>
> org 0x000
>
> bra main
> ; nop
> main: goto main
>
> end
>
> > gpasm -c bad.asm ; gplink -o bad.hex bad.o
> message: using default linker script
> "/usr/home/install/gputils/share/gputils/lkr/16f1518_g.lkr"
> warning: destination address must be word aligned at 0 of section ".org_0"
>
> If I add a nop instruction to make the destination even, there is no warning.
>
> I understand that pic18 uses byte addressing, where 12f and 16f use word addresses, so
> pic18 destinations should always be even. With that in mind, I made this patch:
>
> %diff -u libgputils/gpcofflink.c.orig libgputils/gpcofflink.c
> --- libgputils/gpcofflink.c.orig 2013-07-10 22:00:41.000000000 -0600
> +++ libgputils/gpcofflink.c 2013-07-21 21:42:21.000000000 -0600
> @@ -1415,6 +1415,7 @@
> break;
>
> case RELOCT_BRA:
> + if (class != &proc_class_pic14e)
> if (value & 1) {
> gp_warning("destination address must be word aligned at %#x of section \"%s\"",
> org, section->name);
>
> I don't know if this patch is the right way to fix the error, but I hope it is useful.
>
> Thanks!
> -Richard
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ####@####.####
> For additional commands, e-mail: ####@####.####
>