智能车制作
标题:
汇编高手解读(程序里有汇编)
[打印本页]
作者:
zjsxhwl
时间:
2014-6-12 10:05
标题:
汇编高手解读(程序里有汇编)
asm {
ldd temp; // 带偏移量的间接寻址装载指令
ldx #4
idiv // 有符号数除法指令IDIV
stab ctemp
}
作者:
AI
时间:
2014-6-12 10:45
D=temp,X=4,D/X=temp/4→X,余数→D,ctemp=B(D=A:B)
作者:
zjsxhwl
时间:
2014-6-12 12:06
/****************************************************************************
* motor_update(char channel, char dir) -
*
* Description : Control motor drivers and polarity
* :
* Example : N/A
* Input : motor channel
* Output : MotorCurStyep[?]
* Modify : Motor driver and polarity
* Return : N/A
****************************************************************************/
void motor_update(char channel) //分步方式步进电机刷新程序
{
volatile unsigned char ctemp,*motor_channel;
int temp,itemp;
itemp=MotorFinalStep[channel]-MotorCurStep[channel];//目标步数值减去了当前步数值
if (itemp!=0)
{
if (itemp<0) MotorCurStep[channel]--;
else if (itemp>0) MotorCurStep[channel]++;
//motor_channel=&MCDC0H+channel*4;
motor_channel=(unsigned char *)((unsigned int)&MCDC0 + (unsigned int)(channel*4));
temp = MotorCurStep[channel];
asm {
ldd temp; // 带偏移量的间接寻址装载指令
ldx #4
idiv // 有符号数除法指令IDIV
stab ctemp
}
if(ctemp==0)
{
*motor_channel &=~S0_DTC; //;Duty cycle channel 0 (A low /A PWM)
*(motor_channel+2) &=~S0_DTC; //;Duty cycle channel 1 (B low /B PWM)
}
else if(ctemp==1)
{
*motor_channel &=~S0_DTC; //;Duty cycle channel 0 (A low /A PWM)
*(motor_channel+2) |=S1_DTC; //;Duty cycle channel 1 (B PWM /B low)
}
else if(ctemp==2)
{
*motor_channel |=S1_DTC; //;Duty cycle channel 0 (A PWM /A low)
*(motor_channel+2) |=S1_DTC; //;Duty cycle channel 1 (B PWM /B low)
}
else if(ctemp==3)
{
*motor_channel |=S1_DTC; //;Duty cycle channel 0 (A PWM /A low)
*(motor_channel+2) &=~S0_DTC; //;Duty cycle channel 1 (B low /B PWM)
}
}
else
{
MotorStatus[channel]=OFF;
}
}
作者:
zjsxhwl
时间:
2014-6-12 12:11
单片机是:MC9S12HZ256CPV
作者:
zjsxhwl
时间:
2014-6-12 19:00
有人解读码
欢迎光临 智能车制作 (http://111.231.132.190/)
Powered by Discuz! X3.2