搜索
bottom↓
回复: 0

请教老师在线编程的问题,c中插入汇编语句

[复制链接]

出0入0汤圆

发表于 2011-4-11 10:42:07 | 显示全部楼层 |阅读模式
模拟波特率,发送data数组的数据,延时什么的都没算,只是看看有波形没有结果编译就有个错。
后面把编译结果也发出来,请高手们看看问题在哪里?语法我按照GCC手册上写的,不知道对不对,谢谢了
void   shortdelay()
{   int i,j,k;
          

        asm(  "L2_%=:"    "ldi %0,$10"         :"=r"(j):);
                               
        asm(  "LP_%=:"          "dec %0"             :"=r"(j):"0"(i));
        asm(  "                      ldi %0,$08"          :"=r"(i):);
                               
        asm(  "L1_%=:"   "ANDl _data+%0,$01"   :"=r"(i):);
                               
        asm(  "             IF   _data+%0"            :"=r"(i):);
                               
        asm( "             sbi(PORTD,PD2)"     :"=r"(i):);
        asm( "                       LCALL delay_%=");
        asm( "             ELSE");
                               
        asm( "                           cbi(PORTD,PD2)"     :"=r"(i):);
        asm( "             LCALL delay_%=");
        asm( "     ENDIF");
                                                  
        asm(                   "ror _data+%0"        :"=r"(i):"0"(i));
                               
        asm(                   "DJNZ %0,L1_%="            :"=r"(i):"0"(i));                  
                               
        asm(                   "DJNZ %0,LP_%="       :"=r"(j):"0"(j));
                               
        asm( "delay_%=:"          "ldi          %0, $10"    :"=r"(k):);
        asm( "L3_%=:"              "djnz          %0, L3_%="  :"=r"(k):);
        asm(                   "ret");
}

编译结果:

Build started 11.4.2011 at 10:01:55
avr-gcc  -mmcu=atmega1281 -Wall -gdwarf-2   -DF_CPU=8000000UL -O0 -fsigned-char -MD -MP -MT ok4.o -MF dep/ok4.o.d  -c  ../ok4.c
In file included from ../ok4.c:4:
c:/winavr-20100110/lib/gcc/../../avr/include/util/delay.h:90:3: warning: #warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed"
../ok4.c:49: warning: large integer implicitly truncated to unsigned type
../ok4.c:57: warning: excess elements in array initializer
../ok4.c:57: warning: (near initialization for 'table')
../ok4.c: In function 'Write_256byte':
../ok4.c:386: warning: unused variable 'j'
../ok4.c: In function 'Read_256byte':
../ok4.c:442: warning: control reaches end of non-void function
../ok4.c: In function 'Command_data_check':
../ok4.c:476: warning: implicit declaration of function 'Resend'
../ok4.c:450: warning: unused variable 'b'
../ok4.c:450: warning: unused variable 'a'
../ok4.c: In function 'Receive_command_check':
../ok4.c:493: warning: implicit declaration of function 'IOreceive'
../ok4.c:490: warning: unused variable 'j'
../ok4.c: In function 'IOsend':
../ok4.c:642: warning: unused variable 'j'
../ok4.c:642: warning: unused variable 'i'
../ok4.c: In function 'IOsend_256byte':
../ok4.c:739: warning: implicit declaration of function 'WaitTime0'
../ok4.c: At top level:
../ok4.c:775: warning: conflicting types for 'IOreceive'
../ok4.c:493: warning: previous implicit declaration of 'IOreceive' was here
../ok4.c: In function 'IOreceive':
../ok4.c:813: warning: 'return' with a value, in function returning void
../ok4.c: At top level:
../ok4.c:816: warning: conflicting types for 'WaitTime0'
../ok4.c:739: warning: previous implicit declaration of 'WaitTime0' was here
../ok4.c:823: warning: conflicting types for 'Resend'
../ok4.c:476: warning: previous implicit declaration of 'Resend' was here
../ok4.c: In function 'SYNCH_COMMAND':
../ok4.c:1078: warning: unused variable 't'
../ok4.c: In function 'WRITE_COMMAND':
../ok4.c:1115: warning: unused variable 't'
../ok4.c: In function 'DOWNLOAD_COMMAND':
../ok4.c:1153: warning: unused variable 't'
../ok4.c:1343:1: warning: "/*" within comment
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s: Assembler messages:
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8818: Error: junk at end of line, first unrecognized character is `1'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8836: Error: junk at end of line, first unrecognized character is `0'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8844: Error: unknown opcode `andl'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8844: Error: junk at end of line, first unrecognized character is `0'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8852: Error: unknown opcode `if'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8860: Error: missing ')'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8860: Error: constant value required
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8860: Error: constant value required
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8860: Error: garbage at end of line
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8868: Error: unknown opcode `lcall'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8872: Error: unknown opcode `else'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8876: Error: missing ')'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8876: Error: constant value required
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8876: Error: constant value required
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8876: Error: garbage at end of line
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8884: Error: unknown opcode `lcall'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8888: Error: unknown opcode `endif'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8896: Error: constant value required
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8906: Error: unknown opcode `djnz'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8916: Error: unknown opcode `djnz'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8924: Error: junk at end of line, first unrecognized character is `1'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccDTC03L.s:8932: Error: unknown opcode `djnz'
make: *** [ok4.o] Error 1
Build failed with 1 errors and 25 warnings...

阿莫论坛20周年了!感谢大家的支持与爱护!!

月入3000的是反美的。收入3万是亲美的。收入30万是移民美国的。收入300万是取得绿卡后回国,教唆那些3000来反美的!
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-4-25 09:55

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表