c语言程序如下:
pwmValueTemp[3 * calculationGroupFlag - 3] = vaNumA; //将计算结果输入,临时存放,等待输出
pwmValueTemp[3 * calculationGroupFlag - 2] = vaNumB;
pwmValueTemp[3 * calculationGroupFlag - 1] = vaNumC;
keil的汇编:
475: pwmValueTemp[3 * calculationGroupFlag - 3] = vaNumA; //将计算结果输入,临时存放,等待输出
C:0x09D6 E54E MOV A,calculationGroupFlag(0x4E)
C:0x09D8 75F003 MOV B(0xF0),#0x03
C:0x09DB A4 MUL AB
C:0x09DC 2464 ADD A,#0x64
C:0x09DE F8 MOV R0,A
C:0x09DF A651 MOV @R0,vaNumA(0x51)
476: pwmValueTemp[3 * calculationGroupFlag - 2] = vaNumB;
C:0x09E1 E54E MOV A,calculationGroupFlag(0x4E)
C:0x09E3 75F003 MOV B(0xF0),#0x03
C:0x09E6 A4 MUL AB
C:0x09E7 2465 ADD A,#countNum(0x65)
C:0x09E9 F8 MOV R0,A
C:0x09EA A652 MOV @R0,vaNumB(0x52)
477: pwmValueTemp[3 * calculationGroupFlag - 1] = vaNumC;
478:
C:0x09EC E54E MOV A,calculationGroupFlag(0x4E)
C:0x09EE 75F003 MOV B(0xF0),#0x03
C:0x09F1 A4 MUL AB
C:0x09F2 2466 ADD A,#0x66
C:0x09F4 F8 MOV R0,A
C:0x09F5 A653 MOV @R0,vaNumC(0x53)
countNum是一个全局变量,用来计数,整体的计算次数,可是此处就会把这个变量的值给改变了,为什么会出现这种情况呢?怎么避免? |