近来碰到了一个很奇怪的问题,switch语句竟然能编译出除数为0的情况,而且进入到除数为0错误里面出不来了!!以下是C和编译出来的汇编程序,有没有高手碰到过类似的问题?? C程序: void User_28_Key(uint8 keyvalue) { uint32 temp; switch(keyvalue) { case LEFT:if((pPage.ColorFlag==0)||(pPage.ColorFlag==1)) pPage.ColorFlag = 9; else pPage.ColorFlag--; break; case RIGHT:if(pPage.ColorFlag==9) pPage.ColorFlag = 1; else pPage.ColorFlag++; break; case UP: if(pPage.ColorFlag==0) { pPage.CurrentPage--; pPage.NumFlag = 0; } else { temp = Pow[9-pPage.ColorFlag]; if(Diandu[pPage.NumFlag]/temp%10==0) Diandu[pPage.NumFlag] += 9*temp; else Diandu[pPage.NumFlag] -= temp; } break; case DOWN:if(pPage.ColorFlag==0) { pPage.CurrentPage = USER_NO+1; pPage.NumFlag = 0; } else { temp = Pow[9-pPage.ColorFlag]; if(Diandu[pPage.NumFlag]/temp%10==9) Diandu[pPage.NumFlag] -= 9*temp; else Diandu[pPage.NumFlag] += temp; } break; case ESC: pPage.PrePage = pPage.CurrentPage; pPage.CurrentPage = OTHER_NO; pPage.NumFlag = 0; pPage.ColorFlag = 0; break; case ENTER:if(pPage.NumFlag==7) pPage.NumFlag = 0; else pPage.NumFlag++; pPage.ColorFlag = 0 ; break; default: break; } } 以下是编译出来的汇编程序: [0xe92d4ff8] stmfd r13!,{r3-r11,r14} [0xe59f9660] ldr r9,0x800199c0 ; = #0x8003b498 [0xe59f9660] ldr r9,0x800199c4 ; = #0x8101329e [0xe596500c] ldr r5,[r6,#0xc] [0xe1a0b000] mov r11,r0 [0xe59fa650] ldr r10,0x800199c0 ; = #0x8003b498 [0xe5964008] ldr r4,[r6,#8] [0xe2658009] rsb r8,r5,#9 [0xe7990108] ldr r0,[r9,r8,lsl #2] [0xeb000757] bl __rt_udiv (1) [0xeb000757] bl 0x8001b0e0 ; (__rt_udiv + 0x4) (2) [0xeb000796] bl 0x8001b1e0 ; (__rt_udiv10 + 0x4) (3) [0xe1a07001] mov r7,r1 [0xe3a01000] mov r1,#0 [0xe5960000] ldr r0,[r6,#0] [0xe35b0006] cmp r11,#6 [0x908ff10b] addls pc,pc,r11,lsl #2 [0xea00000b] b 0x800193cc ; (User_28_Key + 0x7c) [0xea00000b] b 0x800193d0 ; (User_28_Key + 0x80) [0xea000004] b 0x800193b8 ; (User_28_Key + 0x68) [0xea00000d] b 0x800193e0 ; (User_28_Key + 0x90) [0xea00003a] b 0x80019498 ; (User_28_Key + 0x148) [0xea00003f] b 0x800194b0 ; (User_28_Key + 0x160) [0xea000012] b 0x80019400 ; (User_28_Key + 0xb0) [0xea000024] b 0x8001944c ; (User_28_Key + 0xfc) [0x0a000001] beq 0x800193c4 ; (User_28_Key + 0x74) [0x0a000001] beq 0x800193c8 ; (User_28_Key + 0x78) [0xe3550001] cmp r5,#1 [0x1a000002] bne 0x800193d4 ; (User_28_Key + 0x84) [0xe3a00009] mov r0,#9 [0xe586000c] str r0,[r6,#0xc] [0xe8bd8ff8] ldmfd r13!,{r3-r11,pc} [0xe2450001] sub r0,r5,#1 [0xeafffffb] b 0x800193cc ; (User_28_Key + 0x7c) [0xeafffffb] b 0x800193d0 ; (User_28_Key + 0x80) [0xe3550009] cmp r5,#9 [0x1a000002] bne 0x800193f4 ; (User_28_Key + 0xa4) [0xe3a00001] mov r0,#1 [0xe586000c] str r0,[r6,#0xc] [0xeafffff6] b 0x800193d0 ; (User_28_Key + 0x80) [0xe2850001] add r0,r5,#1 [0xeafffff3] b 0x800193cc ; (User_28_Key + 0x7c) [0xeafffff3] b 0x800193d0 ; (User_28_Key + 0x80) [0xe3550000] cmp r5,#0 [0x1a000003] bne 0x80019418 ; (User_28_Key + 0xc8) [0xe2400001] sub r0,r0,#1 [0xe5860000] str r0,[r6,#0] [0xe5861008] str r1,[r6,#8] [0xeaffffed] b 0x800193d0 ; (User_28_Key + 0x80) [0xe79a6104] ldr r6,[r10,r4,lsl #2] [0xe79a6104] ldr r6,[r10,r4,lsl #2] [0xe1a00005] mov r0,r5 [0xeb0006c4] bl 0x8001af3c ; (__rt_divtest + 0x4) [0xe3570000] cmp r7,#0 [0x1a000003] bne 0x80019440 ; (User_28_Key + 0xf0) [0xe0850185] add r0,r5,r5,lsl #3 [0xe0860000] add r0,r6,r0 [0xeaffffe3] b 0x800193cc ; (User_28_Key + 0x7c) [0xeaffffe3] b 0x800193d0 ; (User_28_Key + 0x80) [0xe0460005] sub r0,r6,r5 [0xe78a0104] str r0,[r10,r4,lsl #2] [0xeaffffe0] b 0x800193d0 ; (User_28_Key + 0x80) [0xe3550000] cmp r5,#0 [0x1a000003] bne 0x80019464 ; (User_28_Key + 0x114) [0xe3a00010] mov r0,#0x10 [0xe5861008] str r1,[r6,#8] [0xe5861008] str r1,[r6,#8] [0xeaffffda] b 0x800193d0 ; (User_28_Key + 0x80) [0xe7995108] ldr r5,[r9,r8,lsl #2] [0xe79a6104] ldr r6,[r10,r4,lsl #2] [0xe1a00005] mov r0,r5 [0xeb0006b1] bl 0x8001af3c ; (__rt_divtest + 0x4) [0xe3570009] cmp r7,#9 [0xe0850185] add r0,r5,r5,lsl #3 [0xe0850185] add r0,r5,r5,lsl #3 [0xe0460000] sub r0,r6,r0 [0xe78a0104] str r0,[r10,r4,lsl #2] [0xeaffffd0] b 0x800193d0 ; (User_28_Key + 0x80) [0xe0860005] add r0,r6,r5 [0xe78a0104] str r0,[r10,r4,lsl #2] [0xeaffffcd] b 0x800193d0 ; (User_28_Key + 0x80) [0xe3a0003f] mov r0,#0x3f [0xe3a0003f] mov r0,#0x3f [0xe5860000] str r0,[r6,#0] [0xe5861008] str r1,[r6,#8] [0xe586100c] str r1,[r6,#0xc] [0xeaffffc7] b 0x800193d0 ; (User_28_Key + 0x80) [0xe3540008] cmp r4,#8 [0x1a000001] bne 0x800194c0 ; (User_28_Key + 0x170) [0xea000001] b 0x800194c4 ; (User_28_Key + 0x174) [0xea000001] b 0x800194c8 ; (User_28_Key + 0x178) [0xe2840001] add r0,r4,#1 [0xe5860008] str r0,[r6,#8] [0xe586100c] str r1,[r6,#0xc] [0xeaffffbf] b 0x800193d0 ; (User_28_Key + 0x80) [0xe92d4070] stmfd r13!,{r4-r6,r14} [0xe51feaac] ldr r14,0x80018a30 ; = #0x000001b6 [0xe59e000c] ldr r0,[r14,#0xc] [0xe59e000c] ldr r0,[r14,#0xc] [0xe3e01003] mvn r1,#3 [0xe59f44dc] ldr r4,0x800199c8 ; = #0x00000313 [0xe0812100] add r2,r1,r0,lsl #2 [0xe1d410b0] ldrh r1,[r4,#0] [0xe3a05001] mov r5,#1 [0xe1a03215] mov r3,r5,lsl r2 [0xe1a0c231] mov r12,r1,lsr r2 [0xe1a0c231] mov r12,r1,lsr r2 [0x908ff106] addls pc,pc,r6,lsl #2
怎么会编译出(1),(2),(3)这三步呢??还有几个函数跟上述函数类似,都没有这样的问题,就这个函数是这样的,真的很奇怪,左看右看,都没有什么问题啊,找了一两天了,高手请赐教!!
|