From: gomathy b. <kom...@ho...> - 2003-09-11 03:52:19
|
Hi, The following is a part of a reentrant function. (The total function is too big) for ( i =0; i < (4 - nbytes); i++) { snr_in[nbytes + i] = MRcvBuffer[i + byteOffset]; } My problem is that loop does not terminate as I expect. I checked the rst file & I think that one of the registers which holds a value reqd for loop termination check is getting loaded with some other values. Can someone confirm if the problem is due to a bug or something that I have overlooked? Compiler version is 2.3.5 June 14 2003 MINGW32 Compiler switches used are --stack-after-data --xram-loc 0x100 Thanks & Rgds R.Balamurugan Now the relevant part of RST file : Here all variables are of type char. nbytes is at offset 7 snr_in is a char array at offset 3 - here it is stored in r0 i is at offset 10 - but here it seems to be only in the register - r4 MRcvBuffer is a char array in external RAM byteOffset is at r2 6608 ;MfRC500Test.c:988: for ( i =0; i < (4 - nbytes); i++) 19CE 6609 00162$: 6610 ; genMinus 19CE E5 09 6611 mov a,_bp 19D0 24 07 6612 add a,#0x07 19D2 F9 6613 mov r1,a 19D3 74 04 6614 mov a,#0x04 19D5 C3 6615 clr c 19D6 97 6616 subb a,@r1 19D7 FB 6617 mov r3,a ;;;;;;;;; The value of (4 - nbytes) is kept in r3 - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;This part is outside the loop 6618 ; genAssign 19D8 7C 00 6619 mov r4,#0x00 19DA 6620 00140$: ;;;;;;;;;;;;;;;;; loop begins 6621 ; genAssign 19DA 8C 05 6622 mov ar5,r4 6623 ; genCmpLt 6624 ; genCmp 19DC C3 6625 clr c 19DD ED 6626 mov a,r5 19DE 9B 6627 subb a,r3 ;;;;;;;;;;;;; loop termination condition checking - r3 participates 6628 ; genIfxJump 6629 ; Peephole 108 removed ljmp by inverse jump logic 19DF 50 23 6630 jnc 00143$ 19E1 6631 00189$: 6632 ;MfRC500Test.c:993: snr_in[nbytes + i] = MRcvBuffer[i + byteOffset]; 6633 ; genPlus 19E1 E5 09 6634 mov a,_bp 19E3 24 07 6635 add a,#0x07 19E5 F9 6636 mov r1,a 6637 ; Peephole 236.g used r4 instead of ar4 19E6 EC 6638 mov a,r4 19E7 27 6639 add a,@r1 ;;;; nbytes + i is now in acc 6640 ; genPlus 6641 ; Peephole 177 removed redundant mov 19E8 FB 6642 mov r3,a ;;;; r3 which takes part in the loop termination check corrupted 6643 ; Peephole 236.a used r0 instead of ar0 19E9 28 6644 add a,r0 19EA F9 6645 mov r1,a 6646 ; genPlus 6647 ; Peephole 236.g used r2 instead of ar2 19EB EA 6648 mov a,r2 6649 ; Peephole 236.a used r4 instead of ar4 19EC 2C 6650 add a,r4 6651 ; genPlus 19ED 25 2A 6652 add a,_MRcvBuffer 19EF FB 6653 mov r3,a ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; r3 is again affected 6654 ; Peephole 240 use clr instead of addc a,#0 19F0 E4 6655 clr a 19F1 35 2B 6656 addc a,(_MRcvBuffer + 1) 19F3 FD 6657 mov r5,a 19F4 AF 2C 6658 mov r7,(_MRcvBuffer + 2) 6659 ; genPointerGet 6660 ; genGenPointerGet 19F6 8B 82 6661 mov dpl,r3 19F8 8D 83 6662 mov dph,r5 19FA 8F F0 6663 mov b,r7 19FC 12 00 38 6664 lcall __gptrget 6665 ; genPointerSet 6666 ; genNearPointerSet 6667 ; Peephole 192 used a instead of ar3 as source 19FF FB 6668 mov r3,a ;;;;;;;;;;;;;; r3 is loaded with the RHS value of the stmt (why?) 1A00 F7 6669 mov @r1,a 6670 ;MfRC500Test.c:988: for ( i =0; i < (4 - nbytes); i++) 6671 ; genPlus 6672 ; genPlusIncr 1A01 0C 6673 inc r4 6674 ; Peephole 132 changed ljmp to sjmp 1A02 80 D6 6675 sjmp 00140$ 1A04 6676 00143$: _________________________________________________________________ Access Hotmail from your mobile now. http://server1.msn.co.in/sp03/mobilesms/ Click here. |
From: Bernhard H. <ber...@be...> - 2003-09-15 20:27:36
|
> My problem is that loop does not terminate as I expect. I checked the rst > file & I think that one of the registers which holds a value reqd for loop > termination check is getting loaded with some other values. Can someone > confirm if the problem is due to a bug or something that I have overlooked? I didn't examin the assembler output, but I can confirm that SDCC has a 'life range bug'. Your problems are typical for this bug. A workaround is to define i and/or nbytes as volatile. Bernhard |