avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] ASM in WinAVR GCC


From: Panther Electronics
Subject: Re: [avr-gcc-list] ASM in WinAVR GCC
Date: Sat, 11 Jan 2003 12:29:15 +0530

hi,

not that dumb, Just to reduce the bandwidth of the Maillist, i have cut pasted 
the first four lines. what i want to do is move the one value to the port and 
also to a register and then subtract from a constant. and lots more code 
involved.

I am passing only two values. Port & pin. the problem is the constrains placed 
by GCC, "OUT" requires the value to be "I", "I" , "MOV" requires the Value to 
be any reg "r" and "SUBI" requires the value to be in Upper Register "d" or "a".

"mov %0, %1" "\n\t"
"out %2, %1" "\n\t"
"subi %2, 0x07" "\n\t"
"ori  %0, %2" "\n\t"

How to go about this?

the code does not compile, although its dumb, 

am I  or GCC, dumb? ;-). The idea is to port my tested and working ASM codes 
directly to WinAVR

thanks in advance

Srikanth Kamath T




On Fri, 10 Jan 2003 09:44:10 -0700, E. Weddington wrote:
On 10 Jan 2003 at 8:31, Panther Electronics wrote:

> Hi,
>
> can this problem be solved?
>
> #include <avr/io.h>
> #include <avr/interrupt.h>
> #include <avr/signal.h>
>
> #define trg 0
> #define db_time 25
> unsigned char mem_db;
> unsigned char result;
> unsigned volatile char temp, wreg;
>
> unsigned char delays(unsigned char pin, unsigned char port);
>
> int main(void)
> {
> for (;;)
> {
>  temp= 0x01;
>  wreg =0x17;
>  wreg = delays(temp, wreg);
> }
> }
>
> unsigned char delays (unsigned char pin, unsigned char port)
> {
> unsigned char __t;
> asm volatile(
> "nop" "\n\t"
> "nop" "\n\t"
> "mov %0, %1" "\n\t"
> "out %2, %1" "\n\t"
> : "=&r" (__t)
> : "a,I" (pin), "a,I" (port)
> );
> return ( 0 );
> }
>
> >make all"-------- begin --------"
> avr-gcc --version
> avr-gcc (GCC) 3.3 20021209 (experimental)
> Copyright (C) 2002 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There
> is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
> PARTICULAR PURPOSE.
>
> "Size before:"
>  text           data            bss            dec            hex        
>filename
>    0            122              0            122             7a        Dd.hex
> avr-gcc -c -g -Os -funsigned-char -funsigned-bitfields -fpack-struct
> -fshort-enums -Wall -Wstrict-prototypes -Wa,-ahlms=Dd.lst
> -mmcu=at90s2313 -I. Dd.c -o Dd.o Dd.c: In function `delays': Dd.c:37:
> error: operand constraints for `asm' differ in number of alternatives
> make: *** [Dd.o] Error 1 >Exit code: 2
>
> Thanks in advance
>

This may be a dumb question... but, besides the nops, why do you need
to code it in assembly?

Eric
avr-gcc-list at http://avr1.org


avr-gcc-list at http://avr1.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]