完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我在ASM中开发了一个小代码,用于更快的执行,但我没有设法阻塞累加器。下面的代码给了我编译的错误:所以我试图简化情况,我做了这个简单的代码:这给了我编译的错误:我在寻找答案。在互联网上很长一段时间,但没有什么帮助我……能请你吗?最好的问候,RyyMPS:代码工作良好,没有“A”或“B”的俱乐部部分。
以上来自于百度翻译 以下为原文 Hello, I was developping a small code in asm inline for a faster execution but i do not manage to clobber accumulators. The code below : asm volatile ( "MOVSAC A, [%[sonTh]]+=2, W4, [%[coef]]+=4, W5 n" "MPY W4*W5, A, [%[in]]+=2, W4, [%[coef]]+=2, W5 n" "SFTAC A, %[ypow1] n" "MAC W4*W5, A, [%[sonTh]]-=2, W4, [%[coef]]+=4, W5 n" "MPY W4*W5, B, [%[in]]-=2, W4, [%[coef]]-=4, W5 n" "SFTAC B, %[ypow2] n" "MAC W4*W5, B, [%[coef]]-=6, W5, [%[out]]+=2 n" "SAC.R B, [%[out]--]" : /* no output */ : [coef] "y"(&coef), [sonTh] "x"(sonTh), [in] "x"(in), [out] "v"(out), [ypow1] "r"(coef.canal[0].y_pow2), [ypow2] "r"(coef.canal[1].y_pow2) : "w4", "w5", "A", "B" ); that give me this error of compilation : traitement_audio.c:84:9: internal compiler error: asm clobber conflict with input operand Please submit a full bug report, with preprocessed source if appropriate. See <http://www.microchip.com/support> for instructions. make[2]: *** [build/Debug/debug/traitement_audio.o] Error 255 make[1]: *** [.build-conf] Error 2 make: *** [.build-impl] Error 2 So i tried to simplify the situation and I did this easy code : asm volatile ("CLR A" : : : "A"); that give me this error of compilation : traitement_audio.c:89:1: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <http://www.microchip.com/support> for instructions. I looked for an answer on Internet for a very long time, but nothing that helped me... Could you, please ? Best regards, Rémy PS : the codes work very well without "A" or "B" in clubber section. |
|
相关推荐
4个回答
|
|
HI,与纯汇编文件中的实际操作相比,联机DSPIC汇编语法非常有限(而且复杂)。我强烈鼓励您将ASM文件添加到C项目中。XC16编译器手册描述了如果要传递参数,则如何将参数存储在堆栈中。从C中恢复值
以上来自于百度翻译 以下为原文 Hi, The in-line dsPIC assembly syntax is very limitating (and complex) compared to what you can actually do in a pure assembly file. I strongly encourage you to add ASM files to your C project. The XC16 compiler manual describes how parameters are stored in the stack if you want to pass parameters and recover values from C. Regards |
|
|
|
如果希望的话,有内置的C函数与累加器一起工作。
以上来自于百度翻译 以下为原文 There are built-in C functions to work with accumulator if you wish. |
|
|
|
我看到了BuffdIn函数,但我发现它们比ASM内联的要复杂得多……而且,对于我的情况,我不能用ApHyBuuthTuxIn Mac WeAsMac指令来增加增量W13。例如,我选择了ASM内联来获得一个指令号,但我想我会忘记和处理。用一个单独的ASM文件按照你的建议。所以,我没有犯错误吗?我们不能参与累加器吗?
以上来自于百度翻译 以下为原文 I saw the build_in function but I find them again more complicated than asm inline... Moreover for my case, I cannot post-increment W13 with __built_in_MAC wheareas MAC asm instruction can, for example. I chose asm inline to gain a couple of instruction number, but I think I will forget that and deal with a separate asm file as you suggest. So, I did not make mistake ? We can not clubber accumulators ? |
|
|
|
汇编程序一路。当用内联编码时,你必须小心,看起来丑陋,需要更长的代码。编译器会填写额外的东西来获取它们需要的寄存器。最重要的是,任何阅读内联的人都必须理解内联。编码可能需要10倍的时间。错误更难于发现,而是将参数传递给汇编程序代码。
以上来自于百度翻译 以下为原文 Assembler all the way. When coding with inline you have to take care of clobbering, looks ugly and takes a longer to code. There are additional stuff the compiler will fill in to get the registers where they need to be. On top of that, anyone else reading inline will have to understand inline as well. It could take 10 times longer to code. Mistakes are harder to spot. Pass parameters to assembler code instead. .include "xc.inc" .include "LCD7920Lib.inc" .global _lcd7920_line .section lcd7920code,code ;---------------------------------------------------- .equ arg_XS, w0 .equ arg_YS, w1 .equ arg_XE, w2 .equ arg_YE, w3 .equ arg_Color, w4 .equ offsetx, w4 ;reuse .equ offsety, w5 .equ tmpx, w6 .equ tmpy, w7 .equ cnt, w8 .equ xpos, w9 .equ ypos, w10 .equ dir, w11 .equ color, w12 _lcd7920_line: ;check if already opened btss LCD7920_Flag,#LCD7920FLAG_OPEN retlw #LCD7920ERROR_NOTOPEN,w0 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;horizontal line? use fast draw cp arg_YS,arg_YE bra nz,$+8 sub arg_XE,arg_XS,w2 ;width mov #1,w3 ;height bra _lcd7920_srect ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;single pixel? cp arg_XS,arg_XE bra nz,drawline cp arg_YS,arg_YE bra nz,drawline mov arg_Color,w2 bra lcd7920_plot ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ drawline: ;save regs high push.d w8 push.d w10 push w12 mov arg_Color,color mov arg_XS,xpos mov arg_YS,ypos ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;x axis and y axis difference sub arg_XE,arg_XS,offsetx sub arg_YE,arg_YS,offsety ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;absolute for dominant axis mov offsetx,tmpx btsc tmpx,#15 neg tmpx,tmpx mov offsety,tmpy btsc tmpy,#15 neg tmpy,tmpy ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;dominant x, y or the same? cp tmpy,tmpx bra z,samexy bra gtu,yaxis ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;X axis direction mov #1,dir cp arg_XS,arg_XE bra ltu,$+4 mov #-1,dir ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;abs btsc offsetx,#15 neg offsetx,offsetx ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;zero offset? clr A cp0 w2 bra nz,$+6 clr B bra zerox ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;divide and load B mov offsetx,w2 repeat #18-1 divf offsety,w2 lac w0,#-1,B ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ zerox: inc offsetx,cnt ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ looplix: ;plot x,y,color mov xpos,w0 mov #ACCAU,w2 add ypos,[w2],w1 mov color,w2 rcall lcd7920_plot ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;next add A add xpos,dir,xpos dec cnt,cnt bra nz,looplix ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;done pop w12 pop.d w10 pop.d w8 retlw #LCD7920ERROR_OK,w0 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;Y axis direction yaxis: mov #1,dir cp arg_YS,arg_YE bra ltu,$+4 mov #-1,dir ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;abs btsc offsety,#15 neg offsety,offsety ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;zero offset? clr A cp0 w2 bra nz,$+6 clr B bra zeroy ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;divide and load B mov offsety,w2 repeat #18-1 divf offsetx,w2 lac w0,#-1,B ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ zeroy: inc offsety,cnt ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;plot x,y,color loopliy: mov #ACCAU,w2 add xpos,[w2],w0 mov ypos,w1 mov color,w2 rcall lcd7920_plot ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;next add A add ypos,dir,ypos dec cnt,cnt bra nz,loopliy ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;done pop w12 pop.d w10 pop.d w8 retlw #LCD7920ERROR_OK,w0 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ samexy: ;X axis direction mov #1,dir cp arg_XS,arg_XE bra ltu,$+4 mov #-1,dir ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;Y axis direction mov #1,w0 cp arg_YS,arg_YE bra ltu,$+4 mov #-1,w0 mov w0,ACCAH ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;abs btsc offsetx,#15 neg offsetx,offsetx inc offsetx,cnt ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ loopsame: ;plot x,y,color mov xpos,w0 mov ypos,w1 mov color,w2 rcall _lcd7920_plot ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;next add xpos,dir,xpos mov #ACCAH,w2 add ypos,[w2],ypos dec cnt,cnt bra nz,loopsame ;~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;done pop w12 pop.d w10 pop.d w8 retlw #LCD7920ERROR_OK,w0 ;---------------------------------------------------- .end |
|
|
|
只有小组成员才能发言,加入小组>>
5244 浏览 9 评论
2035 浏览 8 评论
1955 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3209 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2260 浏览 5 评论
779浏览 1评论
672浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
598浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
682浏览 0评论
579浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-25 03:25 , Processed in 1.749584 second(s), Total 84, Slave 68 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号