There is simple code
usRDelay(17); Comm_LineOut_Port=SendData.B.Bit02; usRDelay(17); Comm_LineOut_Port=SendData.B.Bit01; usRDelay(17); Comm_LineOut_Port=SendData.B.Bit00; usRDelay(17); Comm_LineOut_Port=1;
I compiled it by keil for arm ver v4.53.0.0(coretex m3)
I got below assambly code
But I meet unexpected code line 0083ae
0083ae e00b B |L1.33736| |L1.33712| DCD TimeAlarmFlags |L1.33716| DCD PwrOn_Redy_Cnt |L1.33720| DCD TimeFlags |L1.33724| DCD PCU_C |L1.33728| DCD GPIO_C |L1.33732| DCD uR0 |L1.33736|
So fuction usRDelay(17); is more delayed. Why unexpected code is generated? What is that code? (p.s. TimeAlarmFlags is defined unsigned char by me, but why that is suddenly located?)
;;;7580 usRDelay(17); 008346 2011 MOVS r0,#0x11 008348 491e LDR r1,|L1.33732| 00834a 7008 STRB r0,[r1,#0] 00834c bf00 NOP |L1.33614| 00834e 481d LDR r0,|L1.33732| 008350 7800 LDRB r0,[r0,#0] ; uR0 008352 1e40 SUBS r0,r0,#1 008354 f01000ff ANDS r0,r0,#0xff 008358 491a LDR r1,|L1.33732| 00835a 7008 STRB r0,[r1,#0] 00835c d1f7 BNE |L1.33614| ;;;7581 Comm_LineOut_Port=SendData.B.Bit02; 00835e f89d0000 LDRB r0,[sp,#0] 008362 f3c00180 UBFX r1,r0,#2,#1 008366 4816 LDR r0,|L1.33728| 008368 6800 LDR r0,[r0,#0] ; GPIO_C 00836a 6800 LDR r0,[r0,#0] 00836c f36120cb BFI r0,r1,#11,#1 008370 4913 LDR r1,|L1.33728| 008372 6809 LDR r1,[r1,#0] ; GPIO_C 008374 6008 STR r0,[r1,#0] ;;;7582 usRDelay(17); 008376 2011 MOVS r0,#0x11 008378 4912 LDR r1,|L1.33732| 00837a 7008 STRB r0,[r1,#0] 00837c bf00 NOP |L1.33662| 00837e 4811 LDR r0,|L1.33732| 008380 7800 LDRB r0,[r0,#0] ; uR0 008382 1e40 SUBS r0,r0,#1 008384 f01000ff ANDS r0,r0,#0xff 008388 490e LDR r1,|L1.33732| 00838a 7008 STRB r0,[r1,#0] 00838c d1f7 BNE |L1.33662| ;;;7583 Comm_LineOut_Port=SendData.B.Bit01; 00838e f89d0000 LDRB r0,[sp,#0] 008392 f3c00140 UBFX r1,r0,#1,#1 008396 480a LDR r0,|L1.33728| 008398 6800 LDR r0,[r0,#0] ; GPIO_C 00839a 6800 LDR r0,[r0,#0] 00839c f36120cb BFI r0,r1,#11,#1 0083a0 4907 LDR r1,|L1.33728| 0083a2 6809 LDR r1,[r1,#0] ; GPIO_C 0083a4 6008 STR r0,[r1,#0] ;;;7584 usRDelay(17); 0083a6 2011 MOVS r0,#0x11 0083a8 4906 LDR r1,|L1.33732| 0083aa 7008 STRB r0,[r1,#0] 0083ac bf00 NOP |L1.33710| 0083ae e00b B |L1.33736| |L1.33712| DCD TimeAlarmFlags |L1.33716| DCD PwrOn_Redy_Cnt |L1.33720| DCD TimeFlags |L1.33724| DCD PCU_C |L1.33728| DCD GPIO_C |L1.33732| DCD uR0 |L1.33736| 0083c8 48fb LDR r0,|L1.34744| 0083ca 7800 LDRB r0,[r0,#0] ; uR0 0083cc 1e40 SUBS r0,r0,#1 0083ce f01000ff ANDS r0,r0,#0xff 0083d2 49f9 LDR r1,|L1.34744| 0083d4 7008 STRB r0,[r1,#0] 0083d6 d1ea BNE |L1.33710| ;;;7585 Comm_LineOut_Port=SendData.B.Bit00; 0083d8 f89d0000 LDRB r0,[sp,#0] 0083dc 49f7 LDR r1,|L1.34748| 0083de 6809 LDR r1,[r1,#0] ; GPIO_C 0083e0 6809 LDR r1,[r1,#0] 0083e2 f36021cb BFI r1,r0,#11,#1 0083e6 48f5 LDR r0,|L1.34748| 0083e8 6800 LDR r0,[r0,#0] ; GPIO_C 0083ea 6001 STR r1,[r0,#0] ;;;7586 usRDelay(17); 0083ec 2011 MOVS r0,#0x11 0083ee 49f2 LDR r1,|L1.34744| 0083f0 7008 STRB r0,[r1,#0] 0083f2 bf00 NOP |L1.33780| 0083f4 48f0 LDR r0,|L1.34744| 0083f6 7800 LDRB r0,[r0,#0] ; uR0 0083f8 1e40 SUBS r0,r0,#1 0083fa f01000ff ANDS r0,r0,#0xff 0083fe 49ee LDR r1,|L1.34744| 008400 7008 STRB r0,[r1,#0] 008402 d1f7 BNE |L1.33780| ;;;7587 ;;;7588 Comm_LineOut_Port=1; 008404 48ed LDR r0,|L1.34748| 008406 6800 LDR r0,[r0,#0] ; GPIO_C 008408 6800 LDR r0,[r0,#0] 00840a f4206000 BIC r0,r0,#0x800 00840e f5006000 ADD r0,r0,#0x800 008412 49ea LDR r1,|L1.34748| 008414 6809 LDR r1,[r1,#0] ; GPIO_C 008416 6008 STR r0,[r1,#0]
Comm_Data PROC ;;;7519 ;;;7520 UINT8 Comm_Data(UINT8 Data) 008052 b51c PUSH {r2-r4,lr} ;;;7521 { 008054 4604 MOV r4,r0 ;;;7522 volatile UINT8_B bR1,SendData; ;;;7523 ;;;7524 //UINT8 R0,R1; ;;;7525 ;;;7526 SendData.U=Data; 008056 9400 STR r4,[sp,#0] ;;;7527 ;;;7528 //R0=0; ;;;7529 //R1=1; ;;;7530 ;;;7531 __disable_irq(); 008058 b672 CPSID i ;;;7532 ;;;7533 CSP_PCU_Set_Direction_Type(PCU_C, PIN_11, PnCR_OUTPUT_PUSH_PULL);//ì¶œë ¥ 00805a 2200 MOVS r2,#0 00805c 210b MOVS r1,#0xb 00805e 48d7 LDR r0,|L1.33724| 008060 6800 LDR r0,[r0,#0] ; PCU_C 008062 f7fffffe BL CSP_PCU_Set_Direction_Type ;;;7534 Comm_LineOut_Port=0; 008066 48d6 LDR r0,|L1.33728| 008068 6800 LDR r0,[r0,#0] ; GPIO_C 00806a 6800 LDR r0,[r0,#0] 00806c f4206000 BIC r0,r0,#0x800 008070 49d3 LDR r1,|L1.33728| 008072 6809 LDR r1,[r1,#0] ; GPIO_C 008074 6008 STR r0,[r1,#0] ;;;7535 ;;;7536 usRDelay(50); 008076 2032 MOVS r0,#0x32 008078 49d2 LDR r1,|L1.33732| 00807a 7008 STRB r0,[r1,#0] 00807c bf00 NOP |L1.32894| 00807e 48d1 LDR r0,|L1.33732| 008080 7800 LDRB r0,[r0,#0] ; uR0 008082 1e40 SUBS r0,r0,#1 008084 f01000ff ANDS r0,r0,#0xff 008088 49ce LDR r1,|L1.33732| 00808a 7008 STRB r0,[r1,#0] 00808c d1f7 BNE |L1.32894| ;;;7537 ;;;7538 Comm_LineOut_Port=1; 00808e 48cc LDR r0,|L1.33728| 008090 6800 LDR r0,[r0,#0] ; GPIO_C 008092 6800 LDR r0,[r0,#0] 008094 f4206000 BIC r0,r0,#0x800 008098 f5006000 ADD r0,r0,#0x800 00809c 49c8 LDR r1,|L1.33728| 00809e 6809 LDR r1,[r1,#0] ; GPIO_C 0080a0 6008 STR r0,[r1,#0] ;;;7539 ;;;7540 CSP_PCU_Set_Direction_Type(PCU_C, PIN_11, PnCR_INPUT_LOGIC);//ìž…ë ¥ 0080a2 2202 MOVS r2,#2 0080a4 210b MOVS r1,#0xb 0080a6 48c5 LDR r0,|L1.33724| 0080a8 6800 LDR r0,[r0,#0] ; PCU_C 0080aa f7fffffe BL CSP_PCU_Set_Direction_Type ;;;7541 usRDelay(27); // Clock high time 4.0us 0080ae 201b MOVS r0,#0x1b 0080b0 49c4 LDR r1,|L1.33732| 0080b2 7008 STRB r0,[r1,#0] 0080b4 bf00 NOP |L1.32950| 0080b6 48c3 LDR r0,|L1.33732| 0080b8 7800 LDRB r0,[r0,#0] ; uR0 0080ba 1e40 SUBS r0,r0,#1 0080bc f01000ff ANDS r0,r0,#0xff 0080c0 49c0 LDR r1,|L1.33732| 0080c2 7008 STRB r0,[r1,#0] 0080c4 d1f7 BNE |L1.32950| ;;;7542 __nop();__nop();__nop(); 0080c6 bf00 NOP 0080c8 bf00 NOP 0080ca bf00 NOP ;;;7543 bR1.B.Bit07=Comm_LineIn_Port;//GPIO_A->PnODR.B.Bit08=R0;//GPIO_A->PnODR.B.Bit08^=1;// 0080cc 48bc LDR r0,|L1.33728| 0080ce 6800 LDR r0,[r0,#0] ; GPIO_C 0080d0 6840 LDR r0,[r0,#4] 0080d2 f3c021c0 UBFX r1,r0,#11,#1 0080d6 f89d0004 LDRB r0,[sp,#4] 0080da f36110c7 BFI r0,r1,#7,#1 0080de 9001 STR r0,[sp,#4] ;;;7544 usRDelay(17); 0080e0 2011 MOVS r0,#0x11 0080e2 49b8 LDR r1,|L1.33732| 0080e4 7008 STRB r0,[r1,#0] 0080e6 bf00 NOP |L1.33000| 0080e8 48b6 LDR r0,|L1.33732| 0080ea 7800 LDRB r0,[r0,#0] ; uR0 0080ec 1e40 SUBS r0,r0,#1 0080ee f01000ff ANDS r0,r0,#0xff 0080f2 49b4 LDR r1,|L1.33732| 0080f4 7008 STRB r0,[r1,#0] 0080f6 d1f7 BNE |L1.33000| ;;;7545 __nop();__nop();__nop(); 0080f8 bf00 NOP 0080fa bf00 NOP 0080fc bf00 NOP ;;;7546 bR1.B.Bit06=Comm_LineIn_Port;//GPIO_A->PnODR.B.Bit08=R1; 0080fe 48b0 LDR r0,|L1.33728| 008100 6800 LDR r0,[r0,#0] ; GPIO_C 008102 6840 LDR r0,[r0,#4] 008104 f3c021c0 UBFX r1,r0,#11,#1 008108 f89d0004 LDRB r0,[sp,#4] 00810c f3611086 BFI r0,r1,#6,#1 008110 9001 STR r0,[sp,#4] ;;;7547 usRDelay(17); 008112 2011 MOVS r0,#0x11 008114 49ab LDR r1,|L1.33732| 008116 7008 STRB r0,[r1,#0] 008118 bf00 NOP |L1.33050| 00811a 48aa LDR r0,|L1.33732| 00811c 7800 LDRB r0,[r0,#0] ; uR0 00811e 1e40 SUBS r0,r0,#1 008120 f01000ff ANDS r0,r0,#0xff 008124 49a7 LDR r1,|L1.33732| 008126 7008 STRB r0,[r1,#0] 008128 d1f7 BNE |L1.33050| ;;;7548 __nop();__nop();__nop(); 00812a bf00 NOP 00812c bf00 NOP 00812e bf00 NOP
;;;7549 bR1.B.Bit05=Comm_LineIn_Port;// 008130 48a3 LDR r0,|L1.33728| 008132 6800 LDR r0,[r0,#0] ; GPIO_C 008134 6840 LDR r0,[r0,#4] 008136 f3c021c0 UBFX r1,r0,#11,#1 00813a f89d0004 LDRB r0,[sp,#4] 00813e f3611045 BFI r0,r1,#5,#1 008142 9001 STR r0,[sp,#4] ;;;7550 usRDelay(17); 008144 2011 MOVS r0,#0x11 008146 499f LDR r1,|L1.33732| 008148 7008 STRB r0,[r1,#0] 00814a bf00 NOP |L1.33100| 00814c 489d LDR r0,|L1.33732| 00814e 7800 LDRB r0,[r0,#0] ; uR0 008150 1e40 SUBS r0,r0,#1 008152 f01000ff ANDS r0,r0,#0xff 008156 499b LDR r1,|L1.33732| 008158 7008 STRB r0,[r1,#0] 00815a d1f7 BNE |L1.33100| ;;;7551 __nop();__nop();__nop(); 00815c bf00 NOP 00815e bf00 NOP 008160 bf00 NOP ;;;7552 bR1.B.Bit04=Comm_LineIn_Port;// 008162 4897 LDR r0,|L1.33728| 008164 6800 LDR r0,[r0,#0] ; GPIO_C 008166 6840 LDR r0,[r0,#4] 008168 f3c021c0 UBFX r1,r0,#11,#1 00816c f89d0004 LDRB r0,[sp,#4] 008170 f3611004 BFI r0,r1,#4,#1 008174 9001 STR r0,[sp,#4] ;;;7553 usRDelay(17); 008176 2011 MOVS r0,#0x11 008178 4992 LDR r1,|L1.33732| 00817a 7008 STRB r0,[r1,#0] 00817c bf00 NOP |L1.33150| 00817e 4891 LDR r0,|L1.33732| 008180 7800 LDRB r0,[r0,#0] ; uR0 008182 1e40 SUBS r0,r0,#1 008184 f01000ff ANDS r0,r0,#0xff 008188 498e LDR r1,|L1.33732| 00818a 7008 STRB r0,[r1,#0] 00818c d1f7 BNE |L1.33150| ;;;7554 __nop();__nop(); 00818e bf00 NOP 008190 bf00 NOP ;;;7555 bR1.B.Bit03=Comm_LineIn_Port;// 008192 488b LDR r0,|L1.33728| 008194 6800 LDR r0,[r0,#0] ; GPIO_C 008196 6840 LDR r0,[r0,#4] 008198 f3c021c0 UBFX r1,r0,#11,#1 00819c f89d0004 LDRB r0,[sp,#4] 0081a0 f36100c3 BFI r0,r1,#3,#1 0081a4 9001 STR r0,[sp,#4] ;;;7556 usRDelay(17); 0081a6 2011 MOVS r0,#0x11 0081a8 4986 LDR r1,|L1.33732| 0081aa 7008 STRB r0,[r1,#0] 0081ac bf00 NOP |L1.33198| 0081ae 4885 LDR r0,|L1.33732| 0081b0 7800 LDRB r0,[r0,#0] ; uR0 0081b2 1e40 SUBS r0,r0,#1 0081b4 f01000ff ANDS r0,r0,#0xff 0081b8 4982 LDR r1,|L1.33732| 0081ba 7008 STRB r0,[r1,#0] 0081bc d1f7 BNE |L1.33198| ;;;7557 __nop();__nop(); 0081be bf00 NOP 0081c0 bf00 NOP
. . . .. (skip). . . . . ;;;7581 Comm_LineOut_Port=SendData.B.Bit02; 00835e f89d0000 LDRB r0,[sp,#0] 008362 f3c00180 UBFX r1,r0,#2,#1 008366 4816 LDR r0,|L1.33728| 008368 6800 LDR r0,[r0,#0] ; GPIO_C 00836a 6800 LDR r0,[r0,#0] 00836c f36120cb BFI r0,r1,#11,#1 008370 4913 LDR r1,|L1.33728| 008372 6809 LDR r1,[r1,#0] ; GPIO_C 008374 6008 STR r0,[r1,#0] ;;;7582 usRDelay(17); 008376 2011 MOVS r0,#0x11 008378 4912 LDR r1,|L1.33732| 00837a 7008 STRB r0,[r1,#0] 00837c bf00 NOP |L1.33662| 00837e 4811 LDR r0,|L1.33732| 008380 7800 LDRB r0,[r0,#0] ; uR0 008382 1e40 SUBS r0,r0,#1 008384 f01000ff ANDS r0,r0,#0xff 008388 490e LDR r1,|L1.33732| 00838a 7008 STRB r0,[r1,#0] 00838c d1f7 BNE |L1.33662| ;;;7583 Comm_LineOut_Port=SendData.B.Bit01; 00838e f89d0000 LDRB r0,[sp,#0] 008392 f3c00140 UBFX r1,r0,#1,#1 008396 480a LDR r0,|L1.33728| 008398 6800 LDR r0,[r0,#0] ; GPIO_C 00839a 6800 LDR r0,[r0,#0] 00839c f36120cb BFI r0,r1,#11,#1 0083a0 4907 LDR r1,|L1.33728| 0083a2 6809 LDR r1,[r1,#0] ; GPIO_C 0083a4 6008 STR r0,[r1,#0] ;;;7584 usRDelay(17); 0083a6 2011 MOVS r0,#0x11 0083a8 4906 LDR r1,|L1.33732| 0083aa 7008 STRB r0,[r1,#0] 0083ac bf00 NOP |L1.33710| 0083ae e00b B |L1.33736| |L1.33712| DCD TimeAlarmFlags |L1.33716| DCD PwrOn_Redy_Cnt |L1.33720| DCD TimeFlags |L1.33724| DCD PCU_C |L1.33728| DCD GPIO_C |L1.33732| DCD uR0 |L1.33736| 0083c8 48fb LDR r0,|L1.34744| 0083ca 7800 LDRB r0,[r0,#0] ; uR0 0083cc 1e40 SUBS r0,r0,#1 0083ce f01000ff ANDS r0,r0,#0xff 0083d2 49f9 LDR r1,|L1.34744| 0083d4 7008 STRB r0,[r1,#0] 0083d6 d1ea BNE |L1.33710| ;;;7585 Comm_LineOut_Port=SendData.B.Bit00; 0083d8 f89d0000 LDRB r0,[sp,#0] 0083dc 49f7 LDR r1,|L1.34748| 0083de 6809 LDR r1,[r1,#0] ; GPIO_C 0083e0 6809 LDR r1,[r1,#0] 0083e2 f36021cb BFI r1,r0,#11,#1 0083e6 48f5 LDR r0,|L1.34748| 0083e8 6800 LDR r0,[r0,#0] ; GPIO_C 0083ea 6001 STR r1,[r0,#0] ;;;7586 usRDelay(17); 0083ec 2011 MOVS r0,#0x11 0083ee 49f2 LDR r1,|L1.34744| 0083f0 7008 STRB r0,[r1,#0] 0083f2 bf00 NOP |L1.33780| 0083f4 48f0 LDR r0,|L1.34744| 0083f6 7800 LDRB r0,[r0,#0] ; uR0 0083f8 1e40 SUBS r0,r0,#1 0083fa f01000ff ANDS r0,r0,#0xff 0083fe 49ee LDR r1,|L1.34744| 008400 7008 STRB r0,[r1,#0] 008402 d1f7 BNE |L1.33780| ;;;7587 ;;;7588 Comm_LineOut_Port=1; 008404 48ed LDR r0,|L1.34748| 008406 6800 LDR r0,[r0,#0] ; GPIO_C 008408 6800 LDR r0,[r0,#0] 00840a f4206000 BIC r0,r0,#0x800 00840e f5006000 ADD r0,r0,#0x800 008412 49ea LDR r1,|L1.34748| 008414 6809 LDR r1,[r1,#0] ; GPIO_C 008416 6008 STR r0,[r1,#0] ;;;7589 CSP_PCU_Set_Direction_Type(PCU_C, PIN_11, PnCR_INPUT_LOGIC);//ìž…ë ¥ 008418 2202 MOVS r2,#2 00841a 210b MOVS r1,#0xb 00841c 48e8 LDR r0,|L1.34752| 00841e 6800 LDR r0,[r0,#0] ; PCU_C 008420 f7fffffe BL CSP_PCU_Set_Direction_Type ;;;7590 ;;;7591 __enable_irq(); 008424 b662 CPSIE i ;;;7592 ;;;7593 return (UINT8)bR1.U; 008426 f89d0004 LDRB r0,[sp,#4] ;;;7594 ;;;7595 } 00842a bd1c POP {r2-r4,pc} ;;;7596 ENDP