#62 BANKISEL with enhaced PIC series

None
closed
Borut Ražem
None
1
2012-11-26
2012-11-21
Gál Zsolt
No

Hello,

I can read in the MPASM user guide the following:

http://ww1.microchip.com/downloads/en/DeviceDoc/33014K.pdf

"The linker will generate the appropriate bank selecting code. For 14-bit instruction
width (most PIC12/PIC16) devices, the appropriate bit set/clear instruction on the IRP
bit in the STATUS register will be generated. But for PIC16 extended instructions,
FSR0H is modified instead of IRP bit (as there is no IRP bit)."

If I compile this code:

prog code

bankisel    100
nop

END

I got this results:
teszt.asm:3: üzenetPage or Bank selection not needed for this device. No code generated.

and I can found only a zero word for NOP instruction in the hex file. So gputils really doesn't make any code for it.

Here is what MPASMX did:

bsf 0x5, 0
bcf 0x5, 0x1
bcf 0x5, 0x2
bcf 0x5, 0x3
nop

I think the different is visible.

Discussion

  • Borut Ražem
    Borut Ražem
    2012-11-21

    If the device has only one bank then the "appropriate" and optimal bank switching code is no code at all since there is nothing to switch.
    So the result depends on the device selected, which is not evident from your description. If the device really has only one bank then the generated code is OK. It not, you found a bug.

    It is already known (at least to me) that MPASM(X) doesn't generate the optimal code for bank / page switching.

    Borut

     
  • Gál Zsolt
    Gál Zsolt
    2012-11-21

    Hello Borut,

    I wasn't enough carful. I am working with a PIC161507 device so the problem appeared for me with this device. I tried to compile this short code for another enchanced core device, for example 16F1939. Here is the result from piklab:

    gpasm -c -I/home/zsolti/Fejlesztes/PIC_Programok/PIC16F/gputils_test/ -pp16f1939 -w0 2011_1106_teszt.asm
    2011_1106_teszt.asm:3: üzenetPage or Bank selection not needed for this device. No code generated.
    gplink -o2011_1106_teszt.hex -c -ainhx32 -m -I/home/zsolti/Fejlesztes/PIC_Programok/PIC16F/gputils_test/ 2011_1106_teszt.o
    message: using default linker script "/usr/local/share/gputils/lkr/16f1939_g.lkr"
    Kész
    Parsing COFF file: /home/zsolti/Fejlesztes/PIC_Programok/PIC16F/gputils_test/2011_1106_teszt.cof
    Device name: "16F1939"

    I agree with you that the code generated by MPASMX isn't optimal at this indirect bank selection if I have few memory or the timing is critical altough I would like to avoid a lot of BANKSEL macro with indirect addressing trough INDF/FSR.

    I don't think it is a bug. My opinion is that it is a little different behviour from mpasmx.

     
  • Borut Ražem
    Borut Ražem
    2012-11-24

    After taking a deeper look into the problem I realized that this is a (not so innocent) missing feature: gpasm doesn't generate the code to modify the FSR0H register for PIC16 extended devices, as indicated by "But for PIC16 extended instructions, FSR0H is modified instead of IRP bit (as there is no IRP bit)."

    I don't consider this as a show stopper for gputils 0.15.0 since I suppose that the new code written specially for PIC16 extended devices will explicitly use the FSR0H register instead of using the BANKISEL directive. But it is a high severity bug since the code ported from non extended PIC16 devices won't work correctly if other then bank 0 is indirectly addressed.

    I'll commit the bug fix immediately after the gpasm 0.15.0 release,

    Borut

     
    Last edit: Borut Ražem 2012-11-24
  • Borut Ražem
    Borut Ražem
    2012-11-26

    • summary: BANISEL with enhaced PIC series --> BANKISEL with enhaced PIC series
    • status: open --> closed
    • assigned_to: Borut Ražem
     
  • Borut Ražem
    Borut Ražem
    2012-11-26

    After rethinking I decided to implement the missing pic 14bit extended devices BANKISEL generation before the gputils 0.15.0 release: sdcc doesn't generate the "native pic 14bit extended" code but "plain pic 14" code, which means that it uses the BANKISEL directive instead of FSR0H register. The sdcc generated code for pic 14bit extended devices won't work correctly with the broken BANKISEL.

    Feature request implemented in svn revision #890.

    Borut

     


Anonymous


Cancel   Add attachments