Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

*ARGH*

*ARGH*

2008-02-29 by Tom

OK, gcc 4.3.1, AVRStudio 4,3 Service Pack 1:


int main (){

uint8_t        var1, var2, var3, var4;            // declare 8 bit 
unsigned variables
                                            // for compatiblity with 8 bit
                                            // registers in the AVR register
                                            //    file

    /*
     *    set the bit patterns for the copy operation
     */

    var1 = 0;                                // all zeros
    var2 = 255;                                // all ones
    var3 = 170;                                // alternating ones and zeros
    var4 = 85;                                // alternating zeros and ones

    /*
     *        copy variables to registers, then copy back to variables
     *        in reverse order
     */

    asm volatile (

    "    mov    r16,    %0        \n"                //  copy the vars 
to the individual
    "    mov r17,    %1        \n"                //  registers
    "    mov r18,    %2        \n"
    "    mov    r19,    %3        \n"

    "    mov    %3,        r16        \n"                //  now copy 
back to vars in reverse
    "    mov    %2,        r17        \n"                //  order
    "    mov    %1,        r18         \n"
    "    mov %0,        r19        \n"

     : "=r" (var1) , "=r" (var2) , "=r" (var3) , "=r" (var4):    // sets 
the vars
                                                                 // for 
input

       "0" (var1) , "1" (var2) , "2" (var3) , "3" (var4) :        // set 
up output
                                                                   // 
vars too

       "r16", "r17", "r18", "r19" );                            // 
clobber the
                                                                   // 
registers

}


    Atb the end, the result in the registers is almost correct, except 
that the values are coming out in the wrong places:

should be:

r16   0x55
r17   0xAA
r18   0xff
r19   0x00

what I am getting:<

r16   0x00
r17   0x00
r18   0xAA
r19   0x55
t20   0xff

   (????)

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.