完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
我在C中有一个短程序,我想在编译时提取汇编版本,但是我不使用C。有人愿意转换它吗?使用ASMLIST和/或-S开关,通过XC8编译器运行它?亚历克…
以上来自于百度翻译 以下为原文 I have a short program in C I would like to extract the assembly version when compiled but I don't use C. Would anyone care to convert it? using the ASMLIST and/or the -S switch by running it through their XC8 compiler? Alec. . |
|
相关推荐
12个回答
|
|
|
|
|
|
|
|
|
任何C编译器都能做到这一点。当然,如果程序很短,你最好从头开始写。
以上来自于百度翻译 以下为原文 Any C compiler can do it. XC8 of course. However, if the program is short, you may be better off writing it from scratch. |
|
|
|
|
|
|
|
|
|
|
|
谢谢。
以上来自于百度翻译 以下为原文 Thanks here it is. PIC16F628A - 20MHz HS xtal Compiler - MikroC for PIC v8 PIC pins; RA0 = digital ST input, quad encoder A RA1 = digital ST input, quad encoder B RB3 = CCP1 output, PWM to motor, HI = ON RB0 = echo encoder A output RB1 = echo encoder A output PIC configs; MCRLE off, BODEN off, BORES off, WDT off, LVP off, PWRT on ******************************************************************************/ // This constant sets the motor speed. The value is in nanoSeconds per pulse, // as we are using a quadrature encoder there are 4 pulses per encoder slot. // My encoder had 36 slots, so that makes 36*4 or 144 pulses per revolution. // Example; 1 motor rev per second = 144 pulses /sec. // nS per pulse = 1 billion / 144 = 6944444 //#define MOTOR_PULSE_PERIOD 1736111 // 4 RPS //#define MOTOR_PULSE_PERIOD 3472222 // 2 RPS #define MOTOR_PULSE_PERIOD 6944444 // 1 RPS //#define MOTOR_PULSE_PERIOD 13888889 // 0.5 RPS // This constant sets the proportional gain. Basically it sets how much // more PWM % is added for each pulse behind that the motor gets. // ie; if set to 10, the PWM is increased by 10% for each pulse behind. // Values must be within 1-50. Values of 10 or 16 worked well with // low motor RPMs, for higher RPMs a smaller value like 2 to 8 can be used. #define MOTOR_PROP_GAIN 10 // global vars unsigned char rpos; // reference position of xtal based freq unsigned char mpos; // actual motor position unsigned char mlag; // amount the motor lags the reference unsigned char enc_new; // holds motor's quadrature encoder data for testing unsigned char enc_last; unsigned long bres; // bresenham accumulator used to make ref frequency unsigned char pins; // temporary var for echoing encoder signals //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void interrupt() { //------------------------------------------------------- // This is TMR0 int, prescaled at 2:1 so we get here every 512 instructions. // This int does the entire closed loop speed control; // 1. updates encoder to see if motor has moved, records it position // 2. updates reference freq generator, records its position // 3. compares the two, sets PWM if motor lags behind reference // 4. limit both counts, so they never roll, but still retain all error //------------------------------------------------------- // clear int flag straight away to give max safe time INTCON.T0IF = 0; // 1. updates encoder to see if motor has moved, records it position enc_new = (PORTA & 0b00000011); // get the 2 encoder bits if(enc_new != enc_last) { if(enc_new.F1 != enc_last.F0) mpos++; // record new motor position else mpos--; enc_last = enc_new; } // 2. updates reference freq generator, records its position bres += 102400; // add nS per interrupt period (512 insts * 200nS) if(bres >= MOTOR_PULSE_PERIOD) // if reached a new reference step { bres -= MOTOR_PULSE_PERIOD; rpos++; // record new xtal-locked reference position } // 3. compares the two, set PWM% if motor lags behind reference if(mpos < rpos) // if motor lagging behind { mlag = (rpos - mpos); // find how far it's lagging behind if(mlag >= (100/MOTOR_PROP_GAIN)) CCPR1L = 100; // full power if is too far behind else CCPR1L = (mlag * MOTOR_PROP_GAIN); // else adjust PWM if slightly behind } else // else if motor is fast, cut all power! { CCPR1L = 0; } // 4. limit both counts, so they never roll, but still retain all error if(rpos>250 || mpos>250) { rpos -= 50; mpos -= 50; } } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //============================================================================= // MAIN //============================================================================= void main() { //------------------------------------------------------- // setup PIC 16F628A CMCON = 0b00000111; // comparators OFF, all pins digital PORTA = 0b00000000; // TRISA = 0b00000011; // RA0,RA1 used for digital ST encoder inputs PORTB = 0b00000000; // TRISB = 0b00000000; // RB3 is CCP1 PWM out, RB0,RB1 are encoder echo outputs // set TMR2 to roll every 100 ticks, PWM freq = 5mil/16/100 = 3125 Hz T2CON = 0b00000111; // TMR2 ON, 16:1 prescale PR2 = (100-1); // PWM total period of 100 // set PWM out on CCP1 CCPR1L = 0; // PWM range 0-100% = start with PWM of 0% CCP1CON = 0b00001100; // CCP1 on, set to PWM mode // TMR0 used for interrupt, makes interrupt every 512 insts OPTION_REG = 0b10000000; // PORTB pullups OFF, TMR0 on, 2:1 prescale //------------------------------------------------------- // setup before main loop Delay_mS(200); // allow PSU voltages time to stabilise // setup vars etc, will be used in interrupt bres = 0; rpos = 0; mpos = 0; // finally start TMR0 roll interrupt INTCON = 0b10100000; // GIE=on, TMR0IE=on //------------------------------------------------------- // main run loop while(1) { //------------------------------------------------- // We don't need to do anything in main loop as the motor speed // control is done entirely in the TMR0 interrupt. //------------------------------------------------- // For convenience in setting up the encoder trimpots, // echo the two encoder pins out two spare PORTB digital outputs! pins = 0; if(PORTA.F0) pins.F0 = 1; if(PORTA.F1) pins.F1 = 1; PORTB = pins; // output those two pins only (PWM output is not affected) } } //----------------------------------------------------------------------------- |
|
|
|
|
|
论坛需要[代码]和[/code ]是小写的,以便作为代码标签工作。
以上来自于百度翻译 以下为原文 The forum requires
to be lowercase in order to work as code tags. |
|
|
|
|
|
嗨,汇编列表和MaFrIP都在ZIPFILE中和MPLAB项目一起。C源代码有一些变化,可以用XC8编译。
以上来自于百度翻译 以下为原文 Hi, Assembler listing and mapfile are in the zipfile together with MPLAB project. There are some changes in c source code, to be able to compile with XC8. Regards, Mysil Attachment(s) C_source.zip (66.69 KB) - downloaded 93 times |
|
|
|
|
|
慢的部分是分割和乘法的。如果Moto Pro的增益是8,那么你可以移动3。也慢。无符号长BRES32位的OPS在8位MpUpHOW写下自己,先做慢的部分。走在公园里…
以上来自于百度翻译 以下为原文 The slow parts are division and multiply. if(mlag >= (100/MOTOR_PROP_GAIN)) CCPR1L = 100; // full power if is too far behind else CCPR1L = (mlag * MOTOR_PROP_GAIN); // else adjust PWM if slightly behind If MOTOR_PROP_GAIN was 8 then you could shift by 3. Also slow. unsigned long bres 32bit ops in 8bit mpu Better off writing yourself, do the slow parts first. Walk in the park... |
|
|
|
|
|
是的,但是那些应该在编译时解决。
以上来自于百度翻译 以下为原文 True, but those (that) should be resolved at compile time |
|
|
|
|
|
没错,但是他使用的是除法10,你知道它是如何发挥出来的。就像NorthGuy所说的,从头开始写,你可以比编译器更好地优化它。
以上来自于百度翻译 以下为原文 True again, but he is using divide by 10 and you know how that plays out. Like NorthGuy said, write from scratch and you can optimize it better than the compiler. |
|
|
|
|
|
谢谢大家,我想要汇编源代码,以便将方法包含在另一个PIC和Aptudia. A中。
以上来自于百度翻译 以下为原文 Thanks all, I wanted the assembly source code in order to include the method in another PIC and purpose. A. |
|
|
|
|
|
很难将C生成代码合并到另一个汇编程序中。
以上来自于百度翻译 以下为原文 It's quite unlikely you'll be able to merge a C-generated code into another assembler project... |
|
|
|
|
|
我并不是打算逐字地使用它,而是想破译密码以便合并它。
以上来自于百度翻译 以下为原文 I did not intend to use it verbatim, but want to decipher the code in order to merge it. A. |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
501 浏览 0 评论
5808 浏览 9 评论
2350 浏览 8 评论
2237 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3543 浏览 3 评论
1155浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1119浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
887浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
501浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-12 06:05 , Processed in 1.008064 second(s), Total 99, Slave 81 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
4697