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

Compiler bug results in crashing code

Below some sample code with the generated assembly. You will see that under some coditions there will be PUSH AR7. This push is never removed from stack and it will keep growing until the program is crashing completely. Uncommenting the commented function will solve the problem, but sometimes one would like to do things like below. (Compiled in SMALL model optimisation=6 and C51 V6.02)


volatile unsigned char xdata Result;
extern void CommentedFunction(void);

void any(void)
{
if ( (Result >= 1) && (Result <= 5) )
{
// CommentedFunction();
}

Function();
}

MOV DPTR,#Result
MOVX A,@DPTR
CLR C
SUBB A,#01H
JC ?C0001
MOVX A,@DPTR
MOV R7,A
PUSH AR7
?C0001:
LCALL Function
RET

Parents
  • I get the following results with C51 V6.03.

                 ; FUNCTION any (BEGIN)
                                               ; SOURCE LINE # 4
                                               ; SOURCE LINE # 5
                                               ; SOURCE LINE # 6
    0000 900000      R     MOV     DPTR,#Result
    0003 E0                MOVX    A,@DPTR
    0004 C3                CLR     C
    0005 9401              SUBB    A,#01H
    0007 4002              JC      ?C0001
    0009 E0                MOVX    A,@DPTR
    000A FF                MOV     R7,A
                                               ; SOURCE LINE # 7
                                               ; SOURCE LINE # 10
    000B         ?C0001:
                                               ; SOURCE LINE # 12
    000B 020000      E     LJMP    Function
                                               ; SOURCE LINE # 13
                 ; FUNCTION any (END)
    

    Contact our sales office and ask for a copy of the latest CD-ROM. There is an update there that will solve the problem.

    Or, you can wait a few days and a new update will be posted to the web site.

    Keil Support

Reply
  • I get the following results with C51 V6.03.

                 ; FUNCTION any (BEGIN)
                                               ; SOURCE LINE # 4
                                               ; SOURCE LINE # 5
                                               ; SOURCE LINE # 6
    0000 900000      R     MOV     DPTR,#Result
    0003 E0                MOVX    A,@DPTR
    0004 C3                CLR     C
    0005 9401              SUBB    A,#01H
    0007 4002              JC      ?C0001
    0009 E0                MOVX    A,@DPTR
    000A FF                MOV     R7,A
                                               ; SOURCE LINE # 7
                                               ; SOURCE LINE # 10
    000B         ?C0001:
                                               ; SOURCE LINE # 12
    000B 020000      E     LJMP    Function
                                               ; SOURCE LINE # 13
                 ; FUNCTION any (END)
    

    Contact our sales office and ask for a copy of the latest CD-ROM. There is an update there that will solve the problem.

    Or, you can wait a few days and a new update will be posted to the web site.

    Keil Support

Children
No data