From: SourceForge.net <no...@so...> - 2005-06-30 04:35:13
|
Bugs item #1230095, was opened at 2005-06-29 21:30 Message generated for change (Comment added) made by jimatjtan You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1230095&group_id=599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: msc51(8051) target Group: None Status: Open Resolution: None Priority: 5 Submitted By: Daniel_Sanchez (daniel_sanchez) Assigned to: Nobody/Anonymous (nobody) Summary: Constants error Initial Comment: Sample code: Whith: #define EISA 20 #define PSWSIZE 6 #define RCDSIZE PSWSIZE+2 // In this case is 8 Doing: for (addr = EISA; addr < (EE_SIZE - RCDSIZE); addr++) The ASM code generated is: ;------------------------------------------------------------ ;Allocation info for local variables in function 'FindFirst' ;------------------------------------------------------------ ;addr Allocated to registers r3 r4 ;------------------------------------------------------------ ;uaccess.c:1171: for (addr = EISA; addr < (EE_SIZE - RCDSIZE); addr++) ; genAssign mov r3,#0x14 mov r4,#0x00 00104$: ; genCmpLt ; genCmp clr c mov a,r3 subb a,#0xFC mov a,r4 subb a,#0x01 ; genIfxJump ; Peephole 108 removed ljmp by inverse jump logic jnc 00107$ Note that 01FC is not equal to EE_SIZE - RCDSIZE. But if in place of RCDSIZE I write 8, then the compiler shows the right value, 01F8. Is this a bug ? Thank you. Best regards Daniel Sanchez Informations required: - Exact command used to run SDCC on this sample code: sdcc --opt-code-size --verbose --out-fmt-ihx %f uaccess.c - SDCC version tested: 2.4.6 #879 (Nov 12 2004)(MINGW32) - My e-mail: das...@uo... ---------------------------------------------------------------------- Comment By: Jim Paris (jimatjtan) Date: 2005-06-30 00:35 Message: Logged In: YES user_id=175928 No, your C code is incorrect. #define creates a preprocessor macro that turns into a literal substitution, not a constant. In this case, (EE_SIZE - RCDSIZE) turns into (EE_SIZE - PSWSIZE + 2) which is very different from (EE_SIZE - (PSWSIZE + 2)). Put parens around the definition of RCDSIZE! ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1230095&group_id=599 |