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

Is this a bug?

Hi, all

I found there is likely a bug in keil c51's compiler(V6.02, Optimization Level = 8)

When compile and link the following program lines:

#include <absacc.h> 
#include <reg52.h> 

#define ADDR201 XBYTE[0x8000] 
bdata unsigned char D201; 
sbit green = D201^2; 
void main(void) 
{ 
  while(1) 
  { 
    green = 1; 
    ADDR201 = D201; 
    green = 0; 
    green = 1; 
    ADDR201 = D201; 
  } 
} 
the result was:

RSEG ?PR?main?TMAIN 
main: 
; SOURCE LINE # 8 
; { 
; SOURCE LINE # 9 
?C0001: 
; while(1) 
; SOURCE LINE # 10 
; { 
; SOURCE LINE # 11 
; green = 1; 
; SOURCE LINE # 12 
SETB green 
; ADDR201 = D201; 
; SOURCE LINE # 13 
MOV DPTR,#08000H 
MOV A,D201 
MOVX @DPTR,A 
; green = 0; 
; SOURCE LINE # 14 
CLR green 
; green = 1; 
; SOURCE LINE # 15 
SETB green 
; ADDR201 = D201; 
; SOURCE LINE # 16 
MOVX @DPTR,A 
; } 
; SOURCE LINE # 17 
SJMP ?C0001 
; END OF main 
END 
there was an obvious error in the assembly code for source line # 16 !
there should be another line:
MOV A,D201
before the line:
MOVX @DPTR,A 
Is it a bug?

0