请教关于在gccavr当中嵌入汇编的问题. 我看了芯艺和另外一本书,参照书中的例句编译不成功.如:芯艺的书当中说,如果 从IO口读取一个数据送内部寄存器当中应当使用下列语句: asm("in %0,%1 " : "=r " (value) : "I" (_SFR_IO_ADDR(PORTD)));
我基本上全抄袭他的内容写出源文件如下: #include <avr/io.h> #include <avr/boot.h> #include <avr/pgmspace.h> #include <util/delay.h> #include <avr/interrupt.h>
int main (void) { asm("in %0,%1 " : "=r " (value) : "I" (_SFR_IO_ADDR(PORTD))); }
编译环境为pn2.0.6.1 出错提示如下: > "make.exe" all
-------- begin -------- avr-gcc (GCC) 3.4.6 Copyright (C) 2006 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.
Compiling C: test0003.c avr-gcc -c -mmcu=atmega8 -I. -gdwarf-2 -DF_CPU=7372800UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wundef -Wa,-adhlns=obj/test0003.lst -std=gnu99 -Wundef -MD -MP -MF .dep/test0003.o.d test0003.c -o obj/test0003.o test0003.c: In function `main': test0003.c:10: error: `value' undeclared (first use in this function) test0003.c:10: error: (Each undeclared identifier is reported only once test0003.c:10: error: for each function it appears in.) make.exe: *** [obj/test0003.o] Error 1
> Process Exit Code: 2
其中我修改了很多地方,编译都出错.请问这个语句我应该怎样写?
|