• AVR Freaks

Hot!Looking for assembly example

Author
kmhillatuha
New Member
  • Total Posts : 12
  • Reward points : 0
  • Joined: 2020/06/25 17:34:33
  • Location: 0
  • Status: offline
2020/07/09 10:41:08 (permalink)
0

Looking for assembly example

Hello folks;

I'm preparing to teach a course using a PIC18F microcontroller this Fall. While the emphasis is on C programming, we do touch on assembly language. So, I'm looking for an example in assembly language. I've found many examples for assemblers other than pic-as, which is provided with xc8.

I have questions near the end.

In the document, "MPLAB XC8 PIC Assembler User's Guide for Embedded Engineers," The following is an account of my work with the example in section 3.

Despite what's said, it's not clear how to use MPLAB X to assist with code to set the configuration bits. I briefly set the build to use xc8, then used the Set Configuration Bits window to produce C code, which I inserted and edited. The editor text replace did quick work to remove the leading text "#pragma" and change " = " to "=". Then I changed the build back to pic-as. Maybe I missed something, is there an easier way?

While the given example builds and loads, in looking at the target program memory, at address $00000 there was no goto statement, to direct the program start. After digging in the assembler user guide I found that the PSECT switch "abs" can work with the ORG directive. Okay, now I see a goto at address $00000.

PSECT resetVec, class="CODE", abs
    ORG  0x00000
resetVec:
    goto main

Next, the debugger is reporting that:
Break point at line 72 in file J:/Courses/Tools/Microchip/Asm03/Asm03.X/main.asm cannot be resolved to a valid program memory address

Questions:
(1) Is the resetVec section given above correct? Perhaps there is something more correct?
(2) Anyone know why the debugger is failing? Perhaps debug symbols should be enabled somehow?
(3) Maybe there is an easier way to produce configuration records for assembly language?

Thanks in advance,



#1

6 Replies Related Threads

    mad_c
    Super Member
    • Total Posts : 1247
    • Reward points : 0
    • Joined: 2010/12/12 17:48:27
    • Location: Brisbane, Australia
    • Status: offline
    Re: Looking for assembly example 2020/07/12 16:15:25 (permalink)
    +1 (1)
    kmhillatuha
     
    Questions:
    (1) Is the resetVec section given above correct? Perhaps there is something more correct?
    (2) Anyone know why the debugger is failing? Perhaps debug symbols should be enabled somehow?
    (3) Maybe there is an easier way to produce configuration records for assembly language?

    Answers:
    (1) You would be better to remove the ORG directive and remove the abs flag from the psect, then link the psect to address 0, e.g. -Wl,-presetVec=0h
    (2) I do not think the current version of the IDE is actually loading the ELF file, so there are no symbols for it to use.
    (3) The current version of the IDE generates C-formatted config directives that need converting before usable with pic-as projects. For the moment, you will just need to do a search-and-change.
     
    Unfortunately, there was little time to get all the compatibility issues in place before the release of the PIC Assembler, but these should be addressed in future releases.
     
    Jeff.
    #2
    dan1138
    Super Member
    • Total Posts : 3717
    • Reward points : 0
    • Joined: 2007/02/21 23:04:16
    • Location: 0
    • Status: offline
    Re: Looking for assembly example 2020/07/12 18:28:17 (permalink)
    +4 (4)
    kmhillatuha
    ... I'm preparing to teach a course using a PIC18F microcontroller this Fall. ...
     
    Questions:
    (1) Is the resetVec section given above correct? Perhaps there is something more correct?
    (2) Anyone know why the debugger is failing? Perhaps debug symbols should be enabled somehow?
    (3) Maybe there is an easier way to produce configuration records for assembly language?



    Answers:
    1. The documentation that Microchip has made available is not well organized and the examples are inadequate. They all are in need of validation and correction.
    2. Symbolic debug is crippled in the pic-as(v2.20) tool chain available with MPLABX v5.50
    3. There are no good ways, mad_c (Jeff) has mentioned using XC8 to generate the #pragma config records that you can edit to be usable with pic-as(v2.20).
    4. A special note that the file name extension must be a capital S (.S), using any other file name extension (.as, .asm, .s) will cause you grief.
    Here is a link to my git repository where I have corrected and validated the examples available in the Microchip document: XC8-PIC-Assembler-UG-for-EE-50002994A.pdf
    post edited by dan1138 - 2020/07/12 19:14:48
    #3
    kmhillatuha
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2020/06/25 17:34:33
    • Location: 0
    • Status: offline
    Re: Looking for assembly example 2020/07/12 21:08:18 (permalink)
    0
    Thanks folks for the replies, dan1138, I'll take a look.
     
    #4
    kmhillatuha
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2020/06/25 17:34:33
    • Location: 0
    • Status: offline
    Re: Looking for assembly example 2020/07/19 16:27:25 (permalink)
    +1 (1)
    Hello folks;
     
    Upon starting MPLAB X today, I noticed an auto-check update to the pic-as toolchain, which I was happy to approve for install. I'm proceeding with caution, but so far debug is looking better...
    #5
    dan1138
    Super Member
    • Total Posts : 3717
    • Reward points : 0
    • Joined: 2007/02/21 23:04:16
    • Location: 0
    • Status: offline
    Re: Looking for assembly example 2020/07/19 17:03:28 (permalink)
    +2 (2)
    kmhillatuha
    Upon starting MPLAB X today, I noticed an auto-check update to the pic-as toolchain, which I was happy to approve for install. I'm proceeding with caution, but so far debug is looking better...

    Yes, the workflow for compile to debug now works as expected.
     
    I wonder what else may have been fixed.
    #6
    kmhillatuha
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2020/06/25 17:34:33
    • Location: 0
    • Status: offline
    Re: Looking for assembly example 2020/07/19 18:28:13 (permalink)
    +1 (1)
    Yes indeed...
     
    #7
    Jump to:
    © 2020 APG vNext Commercial Version 4.5