• AVR Freaks

Hot!XC8 v2.20 doesn't recognize the #asm #endasm directives

Author
LaoMa
Starting Member
  • Total Posts : 38
  • Reward points : 0
  • Joined: 2017/08/01 21:39:42
  • Location: 0
  • Status: offline
2020/05/08 00:07:11 (permalink)
0

XC8 v2.20 doesn't recognize the #asm #endasm directives

Hello,
 
I was using a table in ROM of a PIC16F1704 to read some constant and possibly change them (using memory.c functions).
That worked fine up to XC8 v2.10 .... with 2.20 the table described between #asm .... #endasm is not recognized anymore.
The code is the following, suggested time ago by a post here.

 
    extern const char BAT_Table[];
    extern const char iGAINm;
    extern const char iOFFSETm;
    extern const char uTEMPm;
    extern const char uPIm;
#asm
    PSECT strings, class = CODE, local, delta = 2
    GLOBAL _BAT_Table
    GLOBAL _iGAINm
    GLOBAL _iOFFSETm
    GLOBAL _uTEMPm
    GLOBAL _uPIm
    _BAT_Table
    DW 0x195; //0% 1860 mV
...
#endasm
How the hell I can rewrite this using XC8 v2.20 rules avoiding to use the asm() in front of every line? Assuming its working for labels, too.
 
Thanks
Maurizio 
 
#1

14 Replies Related Threads

    ric
    Super Member
    • Total Posts : 27627
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: XC8 v2.20 doesn't recognize the #asm #endasm directives 2020/05/08 01:08:20 (permalink)
    +1 (1)
    Edit your project properties and switch XC8 from C99 mode to C90 mode.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    LaoMa
    Starting Member
    • Total Posts : 38
    • Reward points : 0
    • Joined: 2017/08/01 21:39:42
    • Location: 0
    • Status: offline
    Re: XC8 v2.20 doesn't recognize the #asm #endasm directives 2020/05/08 01:18:46 (permalink)
    0
    ehi Ric,
     
    I have set C90 already in both XC8 Global Option and XC8 Linker Runtime .....
    I'm sorry, it doesn't work!
     
    Meantime I have tried to use asm inline directive and it seems that is not working, too. 
    I have 2 projects to be combined.... one is compiled only by v2.20, the other only by v2.10.....
    That's driving me crazy..... 
     
    #3
    LaoMa
    Starting Member
    • Total Posts : 38
    • Reward points : 0
    • Joined: 2017/08/01 21:39:42
    • Location: 0
    • Status: offline
    Re: XC8 v2.20 doesn't recognize the #asm #endasm directives 2020/05/08 01:42:24 (permalink)
    +3 (3)
    Hi all, 
    it was easier than expected: put all the code between #asm .... #endasm in a .asm source file added to the projectSmile: Smile
     
    Sorry to have wasted your time..... but here is something anyone can use, particularly beginners.....
     
    Bye bye and thanks to all.
     
    Maurizio
    #4
    RISC
    Super Member
    • Total Posts : 5740
    • Reward points : 0
    • Status: offline
    Re: XC8 v2.20 doesn't recognize the #asm #endasm directives 2020/05/08 03:26:31 (permalink)
    +1 (1)
    Hi,
    Read carefully release notes of XC v2.20 (1st 64 bits version) because it does not anymore support MPASM assembler (legacy Microchip 8 bits assembler ) and uses the PIC assembler (orginated from HiTech).
    Regards
     
    #5
    1and0
    Access is Denied
    • Total Posts : 10903
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: XC8 v2.20 doesn't recognize the #asm #endasm directives 2020/05/08 10:09:11 (permalink)
    0
    RISC
    Read carefully release notes of XC v2.20 (1st 64 bits version) because it does not anymore support MPASM assembler (legacy Microchip 8 bits assembler ) and uses the PIC assembler (orginated from HiTech).

    OP code in Post #1 is NOT of the MPASM assembler. It is XC8's ASPIC assembly code. ;)
     
    #6
    1and0
    Access is Denied
    • Total Posts : 10903
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: XC8 v2.20 doesn't recognize the #asm #endasm directives 2020/05/08 10:15:57 (permalink)
    0
    LaoMa
    That worked fine up to XC8 v2.10 .... with 2.20 the table described between #asm .... #endasm is not recognized anymore.
     
    How the hell I can rewrite this using XC8 v2.20 rules avoiding to use the asm() in front of every line? Assuming its working for labels, too.

    The #asm ... #endasm constructs are NOT supported with the recent XC8 versions; IIRC, it starts with v2.  It now uses the asm() statement for in-line assembly.  As you have found out, it is easier to use an assembly file. ;)
    #7
    ric
    Super Member
    • Total Posts : 27627
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: XC8 v2.20 doesn't recognize the #asm #endasm directives 2020/05/08 16:49:03 (permalink)
    +1 (1)
    1and0
    ...
    The #asm ... #endasm constructs are NOT supported with the recent XC8 versions; IIRC, it starts with v2.  It now uses the asm() statement for in-line assembly.  As you have found out, it is easier to use an assembly file. ;)

    The "Legacy" User Guide that comes with XC8 2.20 still documents the #asm construct, so it should still be available in C90 mode.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #8
    1and0
    Access is Denied
    • Total Posts : 10903
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: XC8 v2.20 doesn't recognize the #asm #endasm directives 2020/05/08 21:41:10 (permalink)
    0
    ric
     
    The "Legacy" User Guide that comes with XC8 2.20 still documents the #asm construct, so it should still be available in C90 mode.

    You're correct.
     
    #9
    LaoMa
    Starting Member
    • Total Posts : 38
    • Reward points : 0
    • Joined: 2017/08/01 21:39:42
    • Location: 0
    • Status: offline
    Re: XC8 v2.20 doesn't recognize the #asm #endasm directives 2020/05/09 21:04:02 (permalink)
    +1 (1)
    Hello,
    like 1and0 has said, the v. 2.x should still accept the #asm directive. And it's partially true, it has worked up to 2.10 included. In the release note is specified that 64 bit versions won't accept anymore those #asm, only the asm() pseudo instructions. V2.20 is my first 64 bit version😐

    Then, for the record, mpasm is still included into the MPLAB X IDE v5.35, if you want to use that. My opinion is that it's better to use XC8 to compile also .asm source files, present time. Of course, the directives could need to be adjusted, then.

    Thanks to you all for comments, they ever help!

    Maurizio
    post edited by LaoMa - 2020/05/09 21:05:59
    #10
    ric
    Super Member
    • Total Posts : 27627
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: XC8 v2.20 doesn't recognize the #asm #endasm directives 2020/05/09 23:50:25 (permalink)
    +1 (1)
    LaoMa
    ...
    In the release note is specified that 64 bit versions won't accept anymore those #asm, only the asm() pseudo instructions.

    Which release notes?
    The notes that comes with XC8 2.20 ( C:/Program Files/Microchip/xc8/v2.20/docs/Readme_XC8_for_PIC.htm ) simply state that #asm/endasm are not supported in C99 mode.
     

    Then, for the record, mpasm is still included into the MPLAB X IDE v5.35, if you want to use that. My opinion is that it's better to use XC8 to compile also .asm source files, present time. Of course, the directives could need to be adjusted, then.

    XC8 has never used MPASM, so whatever version is supplied with the IDE has no effect on XC8.
     
    I just tried compiling this test code using XC8 2.20 in C90 mode, and it worked fine.

    // PIC16F84A Configuration Bit Settings

    // 'C' source line config statements

    // CONFIG
    #pragma config FOSC = HS        // Oscillator Selection bits (HS oscillator)
    #pragma config WDTE = OFF       // Watchdog Timer (WDT disabled)
    #pragma config PWRTE = ON       // Power-up Timer Enable bit (Power-up Timer is enabled)
    #pragma config CP = OFF         // Code Protection bit (Code protection disabled)

    // #pragma config statements should precede project file includes.
    // Use project enums instead of #define for ON and OFF.

    #include <xc.h>

    void main(void) {
        while (1)
        {
    #asm
            incf    PORTB,w
    #endasm
        }
    }


    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #11
    LaoMa
    Starting Member
    • Total Posts : 38
    • Reward points : 0
    • Joined: 2017/08/01 21:39:42
    • Location: 0
    • Status: offline
    Re: XC8 v2.20 doesn't recognize the #asm #endasm directives 2020/05/10 01:16:00 (permalink)
    0
    Ric,
    in the original my project I put that table in an include. h file, called out of main().
    When I tried 1st time to compile it, even if in C90, I got errors for every lines between #asm directive.
    tomorrow I will try to move the #include at the beginning of the main() and compile again.
    its location in the code is strategic, occasionally sw changes a couple of data, I have to avoid to interfere with code that writes in ROM.

    bye
    #12
    LaoMa
    Starting Member
    • Total Posts : 38
    • Reward points : 0
    • Joined: 2017/08/01 21:39:42
    • Location: 0
    • Status: offline
    Re: XC8 v2.20 doesn't recognize the #asm #endasm directives 2020/05/10 01:16:00 (permalink)
    0
    Ric,
    in the original my project I put that table in an include. h file, called out of main().
    When I tried 1st time to compile it, even if in C90, I got errors for every lines between #asm directive.
    tomorrow I will try to move the #include at the beginning of the main() and compile again.
    its location in the code is strategic, occasionally sw changes a couple of data, I have to avoid to interfere with code that writes in ROM.

    bye
    #13
    ric
    Super Member
    • Total Posts : 27627
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: XC8 v2.20 doesn't recognize the #asm #endasm directives 2020/05/10 01:24:07 (permalink)
    +1 (1)
    LaoMa
    Ric,
    in the original my project I put that table in an include. h file, called out of main().

    You should NEVER have executable code in header files, however that shouldn't be the cause of this error.
     

    When I tried 1st time to compile it, even if in C90, I got errors for every lines between #asm directive.
    tomorrow I will try to move the #include at the beginning of the main() and compile again.

    Just to be clear, are you saying the compiler gave errors in the build log, or that the IDE put red squiggles under the lines?
     
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #14
    LaoMa
    Starting Member
    • Total Posts : 38
    • Reward points : 0
    • Joined: 2017/08/01 21:39:42
    • Location: 0
    • Status: offline
    Re: XC8 v2.20 doesn't recognize the #asm #endasm directives 2020/05/10 01:47:47 (permalink)
    -1 (1)
    Ric,
    you are right, but i I used the asm for a table of 14-bit data, more than100 locations, as suggested in this forum. Even if not reccommend, it is not forbidden to put var declaration in include files, MCC does, too.

    the errors where in both compiler output messages and in the code with red squiggles put by IDE.

    in any case, using asm source file closed my issue and even if this discussion is useful, I wouldn't like to waste your time.

    thanks

    Maurizio
    #15
    Jump to:
    © 2020 APG vNext Commercial Version 4.5