完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
XC8用户指南在第5.8节中描述了一种方法,该方法允许C代码调用汇编函数,通过定义参数块的基地址而不是将其放置在编译堆栈上,因此不需要通过单独设置的全局变量传递值,如写F。在指南中,我不能让它工作,因为链接器总是抱怨符号。“A asMyTest'”被定义不止一次。我用两个文件创建了一个测试项目(独立的18F13K50,所有其他选项),一个包含“Meal'”并调用汇编函数的C程序和一个包含测试函数的程序集:根据我对该部分的理解,编译器应该注意到用于“ASMyTest'函数的参数块的REST已经设置为重叠‘APIIPARAM1’变量,而不是重新定义它。但它没有这样做,所以我只看到三个选项,或者我做错了什么,向导是错误的,或者这只是在PRO模式下工作。有什么想法吗?
以上来自于百度翻译 以下为原文 The XC8 User Guide describes, on section 5.8.2, a method that should allow C code to call into assembly functions, by defining the base address of the parameter block instead of placing it on the compiled stack, thus not requiring passing values through global variables set separately, as written further on in the Guide. But I can't get it to work as the linker always complains about the symbol ('?_asm_test') being defined more than once. I created a test project (Standalone, 18F13K50, all other options left alone) with two files, a C one that contains 'main' and calls the assembly function and an assembly one containing the test function: // C #include extern unsigned char asm_test(unsigned char p1, unsigned char p2); void main(void) { #asm extrn api_param1 global ?_asm_test ?_asm_test equ api_param1 #endasm asm_test(1,2); while(1); } ; ASM psect vars,class=COMRAM,abs,ovrld org 0x0000 global api_param1 api_param1: ds 1 psect asm,class=CODE,reloc=2 signat _asm_test, 8313 global _asm_test _asm_test: ADDWF api_param1, W, C RETURN According to my understanding of that section this should make the compiler notice that the address for the parameter block for the 'asm_test' function was already set to overlap the 'api_param1' variable and not redefine it. But it is not doing it. So I see only three options; either I've done something wrong, the Guide is wrong or this only works on PRO mode. Any thoughts on which is it? |
|
相关推荐
3个回答
|
|
我从未尝试过,但是在他们的例子中,他们手动地确定地址,并把绝对值放进等式中。你试图使用一个外部声明的符号。如果你试图按照他们描述的那样去做,会发生什么?
以上来自于百度翻译 以下为原文 I've never tried this, but in their example, they manually determine the address, and put the absolute value into the EQU. You are trying to use an externally declared symbol instead. What happens if you try to do it exactly as they describe? |
|
|
|
与链接器相同的错误,不管使用标签还是绝对地址。
以上来自于百度翻译 以下为原文 The same error from the linker, regardless of using the label or an absolute address. |
|
|
|
我不完全相信编译器支持这一点。它定义了用于装配函数参数所需的符号(因此,您不需要提到的程序集解决方案),但是它不正确地在堆栈中分配该符号,并且无法覆盖符号。我怀疑这一部分的指南应该被删除。既然你正在使用PIC18设备,你应该能够定义这个函数是可重入的,并使用在5.5.3.3节中描述的技术。这避免了具有符号定义的整数的问题。
以上来自于百度翻译 以下为原文 I am not entirely sure that the compiler supports this. It defines the required symbol to use for the assembly function parameters (so you do not need the assembly workaround mentioned), but it does not allocate this symbol correctly in the stack and there is no way to override the symbol. I suspect that this section of the guide should be removed. Since you are using a PIC18 device, you should be able to define the function as being reentrant and use the techique described in Section 5.12.3.3. This avoids the issue of having a symbol defined entirely. Jeff. |
|
|
|
只有小组成员才能发言,加入小组>>
5203 浏览 9 评论
2016 浏览 8 评论
1942 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3188 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2243 浏览 5 评论
754浏览 1评论
641浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
549浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
653浏览 0评论
553浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-5 07:29 , Processed in 1.279047 second(s), Total 81, Slave 64 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号