[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] inline assembler problem
From: |
Matte |
Subject: |
Re: [avr-gcc-list] inline assembler problem |
Date: |
Mon, 19 Jan 2004 07:20:03 +0100 |
Hi
Since some of you wanted to view the whole testprogram in order to help
me track the error I've struggeling with, I post it here. The compiler
I'm using is still the avr-gcc-3.3.1.
The functions in the code below I did implement in order to have some
simple functions to learn from.
#include <inttypes.h>
#define PORT_A 0x1B
#define DDR_A 0x1A
#define PIN_A 0x19
uint8_t read(const uint8_t adr) {
uint8_t p;
asm volatile ("in %0, %1" : "=r" (p) : "I" (adr));
return p;
}
uint8_t fastSBI(const uint8_t port, const uint8_t bit) {
asm volatile("sbi %0, %1" : : "I" (port), "I" (bit));
}
int main(void) {
uint8_t port_a = PORT_A;
uint8_t ddr_a = DDR_A;
uint8_t pin = 3;
uint8_t data;
data = read(port_a);
fastSBI(ddr_a, pin);
return 0;
}
When trying to compile this I get the following errors:
inlasm.c: In function `read':
inlasm.c:11: warning: asm operand 1 probably doesn't match constraints
inlasm.c:11: error: impossible constraint in `asm'
inlasm.c: In function `fastSBI':
inlasm.c:17: warning: asm operand 0 probably doesn't match constraints
inlasm.c:17: warning: asm operand 1 probably doesn't match constraints
Thanks all of you who have tried to help out.
Best Regards
Mattias
> This looks right to me. Show us your *entire* test program.
>
> (I'll bet you are using something like "PORTB" when using your macro
> "read()". If so, you have a different problem! :-)
>
> Best regards,
>
> Bruce
--
Mattias
address@hidden