完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
嗨,我想让一个LED开关和使用汇编代码。真简单。使用两个DEFSZ代码行的各种错误消息。我认为括号现在是必须的。这个代码示例说,Meal.C:81:警告:(1464)传递给函数“的函数”的参数数与函数的原型***不匹配(1){//添加您的应用程序代码COUNT1=100;CONTT2=100;LBL:DEFFSZ(CONTT1);GOTO LBL;DEFSZ(CONTT2)Goto LBL;HythBealDeDigToGeLe[();//Y-DelayyMS(500);//(i=0;i & lt;10000;i++);}*******************史提夫。
以上来自于百度翻译 以下为原文 Hi, I'm trying to get an LED to toggle on and off using assembly code. Real simple. Various error messages with the two decfsz lines of code. I think the brackets are now necessary. This code example says, main.c:81: warning: (1464) number of arguments passed to function "_decfsz" does not match function's prototype ******* while (1) { // Add your application code count1 = 100; count2 = 100; lbl: decfsz(count1) ; goto lbl ; decfsz(count2) ; goto lbl ; HeartbeatLED_Toggle(); //__delay_ms(500); //for(i = 0; i < 10000; i++); } ******* Any help with this one would be appreciated. Steve |
|
相关推荐
19个回答
|
|
|
DEFSZ是一个汇编指令,程序的其余部分都是用C语言编写的。
以上来自于百度翻译 以下为原文 decfsz is an assembly instruction. All the rest of your program is written in C. |
|
|
|
|
|
如果你想在C语言中延时,有很多更好的方法。如果你想在汇编语言中完成,那么你需要重新开始。
以上来自于百度翻译 以下为原文 If you want a delay in C, there are much better ways to do it. If you want to do it all in assembly, then you need to start again. |
|
|
|
|
|
除了QHB的评论之外,我还要补充一下,你有一个无限循环,第二个DEFSZ永远不会到达。
以上来自于百度翻译 以下为原文 In addition to qhb's comment, I'd add that you have an infinite loop and the second decfsz will never be reached. GP |
|
|
|
|
|
当内环为零时,第二个DEFSZ应该执行。
以上来自于百度翻译 以下为原文 Second decfsz should execute when the inner loop gets to zero. |
|
|
|
|
|
好啊!谢谢你的回复。那么我怎么用C做一些汇编呢?很难找到可以在新环境中使用的代码示例。我是新来的,在这里挣扎,干杯,
以上来自于百度翻译 以下为原文 OK! Thanks for the replies. So how do I do some assembly in with the C ?? It is very difficult to find examples of code that can be used in the new environment. I'm new and floundering here. Cheers, |
|
|
|
|
|
我得出的结论是,C代码是写在一个文件和汇编在另一个?不像PHP和HTML那么…
以上来自于百度翻译 以下为原文 Do I come to the conclusion that C code is written in one file and assembly in the other ? Not like php and html then ... |
|
|
|
|
|
假设两个计数器变量是全局变量,请尝试:
以上来自于百度翻译 以下为原文 Assuming the two counter variables are global variables, try this: #asm lbl: decfsz _count1 goto lbl decfsz _count2 goto lbl #endasm |
|
|
|
|
|
干杯,它没有吐出as m和endasm,至少…但它确实说'未定义的符号计数1'的行内的as m代码(decfsz行)我已经宣布它以外的主要作为一个全球变量,我相信,它不吐在开始到100。我是如此初学者嗯!我从http://dos4..com/PIC./PIC..html********void main(void){//初始化设备SYSTEM_Initialize();//当使用中断时,需要将全局和外围中断可启用位//使用下列宏://启用全局中断//INTERRUPT_GlobalInter.Enable();//启用外围中断//INTERRUPT_.pheralInter.Enable();//禁用全局中断//INTERRUPT_GlobalInter..ble();//禁用外围中断//INTERRUPT_.pheralInter..ble();同时(1){//添加应用程序代码count1=100;count2=100;#asm lbl: decfsz(count1);goto lbl;decfsz(count2);goto lbl;#endasm HeartbeatLED_Toggle();/u._ms(500);//for(i=0;i<10000;i+);}******************
以上来自于百度翻译 以下为原文 Cheers, It didn't spit the #asm and #endasm at least ... But it did say 'undefined symbol count1' for the lines within the asm code (the decfsz lines) I have declared it outside the main as a global variable I believe and it doesn't spit at the initialising to 100. I'm SUCH a beginner eh! I got the code from http://dos4ever.com/PICdelay/PICdelay.html ****** void main(void) { // initialize the device SYSTEM_Initialize(); // When using interrupts, you need to set the Global and Peripheral Interrupt Enable bits // Use the following macros to: // Enable the Global Interrupts //INTERRUPT_GlobalInterruptEnable(); // Enable the Peripheral Interrupts //INTERRUPT_PeripheralInterruptEnable(); // Disable the Global Interrupts //INTERRUPT_GlobalInterruptDisable(); // Disable the Peripheral Interrupts //INTERRUPT_PeripheralInterruptDisable(); while (1) { // Add your application code count1 = 100; count2 = 100; #asm lbl: decfsz(count1) ; goto lbl ; decfsz(count2) ; goto lbl ; #endasm HeartbeatLED_Toggle(); //__delay_ms(500); //for(i = 0; i < 10000; i++); } } ************ |
|
|
|
|
|
C全局变量的汇编映射从下划线字符开始。再仔细看看我的片段。
以上来自于百度翻译 以下为原文 Assembly mapping of C global variable begins with an underscore character. Look carefully again at my snippet. |
|
|
|
|
|
提示:如果在C函数*ALWAYS*中写入内联程序集的#asm/#endasm块,则用{大括号:您可以在XC8用户指南的第6章中阅读有关ASPIC程序集语法的内容。它不是*MPASM兼容。
以上来自于百度翻译 以下为原文 Hint: if writing a #asm/#endasm block of inline assembly within a C function *ALWAYS* surround it with { braces: { #asm ; assembly code goes here #endasm } You can read about ASPIC assembler syntax in chapter 6 of the XC8 user guide. Its *NOT* MPASM compatible. |
|
|
|
|
|
|
|
|
|
|
|
在C程序中添加延迟仍然是一种愚蠢的方式。根本不需要做内联汇编程序。你有一个调用到了y-DelaySyMy()的注释。我猜你没有得到它的工作,因为你没有阅读有关它在XC8用户指南的文件。
以上来自于百度翻译 以下为原文 It's still a silly way to add a delay into a C program. There's no need to do inline assembler at all. You had a call to __delay_ms() commented out. I'm guessing you didn't get it to work, because you didn't read the documentaiton about it in the XC8 User Guide. |
|
|
|
|
|
谢谢各位…我现在在每个DEFSZ线路上都有两个错误……无法分辨标识符、计数和DEFSZ!{{****.(1){//添加应用程序代码count1=100;count2=100;{asm lbl: decfsz(_count1);goto lbl;decfsz(_count2);goto lbl;endasm}HeartbeatLED_Toggle();/u._ms(500);//for(i=0;i<10000;i+);}******
以上来自于百度翻译 以下为原文 Thanks guys ... I get two errors on each of the decfsz lines now ... 'Unable to resolve identifier _count and decfsz !!' ****** while (1) { // Add your application code count1 = 100; count2 = 100; { #asm lbl: decfsz (_count1); goto lbl; decfsz (_count2); goto lbl; #endasm } HeartbeatLED_Toggle(); //__delay_ms(500); //for(i = 0; i < 10000; i++); } ****** |
|
|
|
|
|
嗨,好的,很好。我所要做的就是得到一些代码来闪烁LED开关,这样我就可以采取措施来确定系统时钟!我想C代码太复杂了,我无法分析WRT时钟周期。现在你要告诉我,我是一个莳萝…-)干杯,
以上来自于百度翻译 以下为原文 Hi qhb ... Nope. It works fine. All I'm trying to do is get some code to flash an LED on and off so I can take a measurement to determine the system clock !! I think the C code is too complex for me to analyse wrt clock cycles. Now you're going to tell me I'm a dill ... :-) Cheers, |
|
|
|
|
|
提示,如果您致力于在汇编程序中完成这项工作,那么按照1和0告诉您的去做。
以上来自于百度翻译 以下为原文 Hint, if you're committed to doing this in assembler, then do EXACTLY what 1and0 told you to. If you want to do this the easy way, read up on how to use __delay_ms() |
|
|
|
|
|
好啊。你真是个笨蛋。C代码正好是两行。一行告诉编译器你的时钟速度是多少,第二行是延迟时间。这比用内联asm挣扎要简单得多。
以上来自于百度翻译 以下为原文 ok. You're a dill. The C code is precisely two lines. One to tell the compiler what your clock speed is, and the second to do the delay. Much simpler than floundering around with inline asm. |
|
|
|
|
|
以上来自于百度翻译 以下为原文 //Assume clock is 8MHz #define _XTAL_FREQ 8000000 void main(void) { // initialize the device SYSTEM_Initialize(); while (1) { HeartbeatLED_Toggle(); __delay_ms(500); } } |
|
|
|
|
|
现在我必须同意@ QHB。我认为OP在C.学习嵌入式汇编
以上来自于百度翻译 以下为原文 Now I have to agree with @qhb. I thought OP was trying to learn embedding assembly in C. |
|
|
|
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
514 浏览 0 评论
5819 浏览 9 评论
2351 浏览 8 评论
2238 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3545 浏览 3 评论
1170浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1123浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
893浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
514浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-17 17:05 , Processed in 1.908394 second(s), Total 110, Slave 93 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1495