This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Keil -O0 and -O1 optimize

My code

Fullscreen
1
2
while(usart_transmit_status);
usart_transmit_status = 1;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

translate at -O0

Fullscreen
1
2
3
4
0x08001EB4 4807 LDR r0,[pc,#28] ; @0x08001ED4
0x08001EB6 7800 LDRB r0,[r0,#0x00]
0x08001EB8 2800 CMP r0,#0x00
0x08001EBA D1FB BNE 0x08001EB4
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

and translate at -O1

Fullscreen
1
2
3
4
0x08001A6E 4907 LDR r1,[pc,#28] ; @0x08001A8C
0x08001A70 7808 LDRB r0,[r1,#0x00]
0x08001A72 2800 CMP r0,#0x00
0x08001A74 D1FD BNE 0x08001A72
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

It leads to an error because R0 changes in interruption

0