The APP/NO APP brackets show where in optimized code your asm
statement got put.  The intervening operations which corrupt registers
are gcc attempting to move values into registers to meet the
constraints on the asm statement.

Try combining the two movx operations into a single asm statement to
prevent this.

__asm__ __volatile__ ("movx.a %1, %2\n\tmovx.b @%1, %0", <other stuff here>)

would do it, though you'll have to play around to figure out what
"other stuff" is.  You probably don't have to tell gcc that %2 is an
output.

Peter

On Sun, Apr 17, 2011 at 1:41 PM, Matthias Ringwald <[email protected]> wrote:
> Hi
>
> sorry for highjacking this thread, but I'm also struggling to access data put 
> into the fartext segment.
>
> On 13.04.2011, at 21:23, JMGross wrote:
>> ..But I have something I wrote for accessing upper flash as data storage.
>>
>> static inline unsigned char FlashReadByte (unsigned long address){
>>  unsigned char result;
>>  unsigned int sr, flash;
>>  __asm__ __volatile__ ("mov r2,%0":"=r"(sr):);                               
>>   // save SR before disabling IRQ
>>  _DINT();
>>  __asm__ __volatile__ ("movx.a %1,%0":"=r"(flash):"m"(address));
>>  __asm__ __volatile__ ("movx.b @%1, %0":"=r"(result):"r"(flash));
>>  __asm__ __volatile__ ("mov %0,r2"::"r"(sr));                                
>>   // restore previous SR and IRQ state
>>  return result;                                                              
>>   // aligned address -> low-byte contains result
>> }
>
> I'm using the mspgcc4-20110312 release (on mac ox), and the code above 
> doesn't work for me (yet). Are there some extra compiler flags aside from the 
> e.g. -mmcu=msp430x5438 switch?
>
> I was trying to read data at 0x10000, but the function a) wasn't inlined, and 
> b) did return the data from 0x00000.
> I've single stepped this function and got irritated by  generated assembly 
> code, which is much longer than the inline asm above.
>
> I'm getting this:
>
>        .p2align 1,0
>        .type   FlashReadByte,@function
> /***********************
>  * Function `FlashReadByte'
>  ***********************/
> FlashReadByte:
>        push    r4
>        add     #llo(-10), r1
>        mov     r1, r4
>        /* prologue ends here (frame size = 10) */
> .L__FrameSize_FlashReadByte=0xa
> .L__FrameOffset_FlashReadByte=0xc
>        mov     r14, 6(r4)
>        mov     r15, 6+2(r4)
> /* #APP */
>  ;  147 "main.c" 1
>        mov r2,r15
>  ;  0 "" 2
> /* #NOAPP */
>        mov     r15, 2(r4)
> /* #APP */
>  ;  149 "main.c" 1
>        movx.a 6(r4),r15
>  ;  0 "" 2
> /* #NOAPP */
>        mov     r15, @r4
>        mov     @r4, r15
> /* #APP */
>  ;  150 "main.c" 1
>        movx.b @r15, r15
>  ;  0 "" 2
> /* #NOAPP */
>        mov.b   r15, 4(r4)
>        mov     2(r4), r15
> /* #APP */
>  ;  151 "main.c" 1
>        mov r15,r2
>  ;  0 "" 2
> /* #NOAPP */
>        mov.b   4(r4), r15
>
>        /* epilogue: frame size = 10 */
>        add     #10, r1
>        pop     r4
>        ret
> .Lfe3:
>        .size   FlashReadByte,.Lfe3-FlashReadByte
> ;; End of function
>
> In the "movx.a 6(r4),r15", 0x10000 was stored in r15, but in the following 
> two lines (mov r15, @r4 , mov @r4, r15), the upper bits get lost. I assume, 
> if there wouldn't be that #NOAPP stuff, it would be fine. What error do I 
> make?
>
>
> Best
>  Matthias
>
> p.s. just starting with this toolchain and MSP430 in general.
>
>
>
> ------------------------------------------------------------------------------
> Benefiting from Server Virtualization: Beyond Initial Workload
> Consolidation -- Increasing the use of server virtualization is a top
> priority.Virtualization can reduce costs, simplify management, and improve
> application availability and disaster protection. Learn more about boosting
> the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
> _______________________________________________
> Mspgcc-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to