We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
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)