• AVR Freaks

Hot!Clobber values in Inline assembly in XC32

Author
onnimikki
Starting Member
  • Total Posts : 51
  • Reward points : 0
  • Joined: 2013/07/06 06:06:17
  • Location: 0
  • Status: offline
2020/07/26 03:44:41 (permalink)
0

Clobber values in Inline assembly in XC32

Hi,
 
I'm writing some inline assembly for the PIC32MX in XC32 and want to verify the usage of the clobber list.  I want to protect the original contents of the v0 register so use the clobber list (the values that appear after the third colon).  Is the usage of quotation marks valid?  The compiler doesn't error out but I'm not seeing anything differnt in the disassembly listing, so I'm not sure if it's being considered or just being ignored at compile time.
 
    asm("lw $v0, my_var"    :   :   :"v0");           // copy the global variable value in SRAM into register V0
 
thanks!
 
James
 
#1

3 Replies Related Threads

    andersm
    Super Member
    • Total Posts : 2839
    • Reward points : 0
    • Joined: 2012/10/07 14:57:44
    • Location: 0
    • Status: offline
    Re: Clobber values in Inline assembly in XC32 2020/07/26 03:56:25 (permalink)
    0
    That tells the compiler that the contents of register $v0 has been destroyed. It would only affect the output if there was some previously loaded value in $v0 that the compiler needed later on.
    #2
    onnimikki
    Starting Member
    • Total Posts : 51
    • Reward points : 0
    • Joined: 2013/07/06 06:06:17
    • Location: 0
    • Status: offline
    Re: Clobber values in Inline assembly in XC32 2020/07/26 04:33:01 (permalink)
    +1 (1)
    Hi
     
    I suspect that we're saying the same thing.  My understanding of the clobber list is that it informs the Assembler/Compiler that, for the particular asm("") call we've inserted that we're using a register (v0, in this case) and that if there was something in that register prior to the asm("") call, then the assembler should take measures to store that value prior to the asm("") call and then restore it after (to prevent it from being destroyed by the asm("") call).
     
    Unless you take the clobber list to mean something else...
     
    James
     
    #3
    JasonK
    Moderator
    • Total Posts : 3411
    • Reward points : 0
    • Joined: 2003/11/14 09:49:40
    • Location: Microchip Technology in Arizona, USA
    • Status: offline
    Re: Clobber values in Inline assembly in XC32 2020/07/28 15:35:37 (permalink)
    +1 (1)
    Just out of curiosity, what's the need for inline assembly? Is there something you can't write in C?

    Jason Kajita
     Follow me on Twitter
    http://support.microchip.com for urgent questions
    #4
    Jump to:
    © 2020 APG vNext Commercial Version 4.5