Deja Vu Andy,

Didn't you post this already some time ago? And didn't I reply that you
could send me the code offline?

Greets,
Maarten


> Maarten,
>
> Many thanks for the excellent response so far.
> Please bear with the following lengthy explanation....
>
>
> It _IS_ a small app: the .map file shows all the code:-
>
>       Area                               Addr   Size   Decimal Bytes
> (Attributes)
>       --------------------------------   ----   ----   ------- -----
> ------------
>       CSEG                               407A   0CE8 =   3304. bytes
> (REL,CON,CODE)
>
>               Value  Global
>          --------  --------------------------------
>         0C:407A    _app_entry
>         0C:40F7    _main
>         0C:40FD    _Timer_Init
>         0C:4169    _Timer_Allocate
>         0C:4228    _Timer_AllocateTimeout
>         0C:4232    _Timer_Deallocate
>         0C:4270    _Timer_HasExpired
>         0C:42D4    _Timer_ISR0Guts
>         0C:43A9    _Timer_DelayUS
>         0C:43ED    _Timer_DelayMS
>         0C:4419    _UART_Init
>         0C:4427    _UART_TxCh
>         0C:4431    _UART_RxAvailable
>         0C:4438    _UART_RxCh
>         0C:448D    _UART_RxHexU08
>         0C:44B1    _UART_RxHexU16
>         0C:44D4    _UART_TxHexU08
>         0C:44EE    _Console_PollOnce
>         0C:4673    _strlen
>         0C:4697    _putchar
>         0C:469A    _HexToDec
>         0C:46D5    _DecToHex
>         0C:46F3    ___printf_no_irq
>         0C:4727    _do_stuff1
>         0C:473D    _do_stuff0
>         0C:475E    _vprintf
>         0C:4777    _printf
>         0C:4837    __print_format
>         0C:4D25    __mulint
>         0C:4D25    __mulint_dummy
>         0C:4D42    __gptrget
>         0C:4D5E    __sdcc_external_startup
>
> However the .ihx output has inserted a spurious extended address record.
>
>       <snippet>
>       :0E4EB900616420524F4D2F434F4445206164E9
>       :0E4EC7006472657373203078585858580A0A80
>       :014ED50000DC
>       :0E4ED6004F69202D2057617463682077686152
>       :0E4EE4007420796F7527726520646F696E67A0
>       :0E4EF200206661742066696E676572730A003F
>       :020000040001F9                                         ;
> spurious!
>       :08467300AA82AB83ACF07D00CC                             ;
> _strlen not in high segment
>       :0E467B008A828B838CF0124D42FEA3AA82AB82
>       :0746890083EE60030D80EBDE
>       </snippet>
>
>
> I've done some more work on this, and I'm pretty sure it's a linker bug.
>
> as/link/mcs51/lkihx.c reads as follows:-
>
>       VOID
>       hexRecord(unsigned addr, int rtvalIndex)
>       {
>           Addr_T chksum;
>           int i, overrun, bytes;
>
>           for (i = rtvalIndex, chksum = 0; i < rtcnt; i++) {
>               if (rtflg[i]) {
>                   if (addr + ++chksum > 0xffff)
>                       break;
>               }
>           }
>           if (chksum == 0)
>               return;         // nothing to output
>
>           if ( (lastHexAddr > addr) && (rflag) ) {         /* <==
> BUG?? */
>               overrun = hexPageOverrun + 1;
>               ihxExtendedLinearAddress(lastExtendedAddress + overrun);
>               hexPageOverrun = overrun;
>               hexRecord(addr, rtvalIndex);
>               return;
>           }
>         ... etc.
>       }
>
>
> I think the line I've marked assumes that the output is always
> ascending, therefore if (lastHexAddr > addr) it must have wrapped around
> into a different bank. However, look at the .ihx output above: the
> addresses are rising (E4ED, E4EE, E4EF) then the next address is 4673 -
> still in the common area, but less than the previous address, so it
> inserts the extended record.
>
> I've tried a replacement as follows. This 'fixes' the problem for this
> case, but is not extendable to >2 banks (and obviously I don't know the
> code that well, so I may break something else...) Can you confirm I'm on
> the right lines, or suggest a better way?
>
>           unsigned masked1, masked2;
>           masked1 = lastHexAddr & ~0xFFFFUL;
>           masked2 = addr & ~0xFFFFUL;
>
>           /* Is this record in the same bank as previous? */
>           if ( (masked1 != masked2) && (rflag) ) {
>                 overrun = hexPageOverrun + 1;
>               ihxExtendedLinearAddress(lastExtendedAddress + overrun);
>               hexPageOverrun = overrun;
>               hexRecord(addr, rtvalIndex);
>               return;
>           }
>
> I've tried to compress the app even further, to get something small
> enough to submit as a how-to-reproduce sample. However the problem goes
> away if I get it any smaller. So, I'm stuck with 8 compilation units and
> makefile. I can send you this off-list if you need it.
>
> Regards,
> Andy
>
>
>
>>
>> Date: Wed, 28 Jan 2009 20:40:22 +0100
>> From: "Maarten Brock" <sourceforge.br...@dse.nl>
>> Subject: Re: [Sdcc-user] Help with code-banking
>>
>> Andy,
>>
>> If you still have code above 0x00010000 as indicated by
>> the second record you mention, you either have placed
>> code above that address yourself with a option for the
>> linker or your program is not "a small app".
>>
>> Maarten
>>
>> > Thanks a lot Maarten,
>> >
>> > I've made sense of the extended address record. However one
>> thing still
>> > confuses me. If I build a small app that all fits in the
>> common area,
>> > the output.ihx still contains two extended address records,
>> along the
>> > lines of:-
>> >
>> > :020000040000FA     // I guess this means bank0?
>> > ..
>> >   <some data records>
>> > ..
>> > :020000040001F9     // I guess this means bank1?
>> > ..
>> >   <more data records>
>> > ..
>> > :0400000500000000F7
>> > :00000001FF
>> >
>> > I guess the linker must think the banked area starts at a
>> lower address.
>> > How do I set the banked area?
>> > (or have I misunderstood completely?!)
>> >
>
>
>
> ------------------------------------------------------------------------------
> Create and Deploy Rich Internet Apps outside the browser with
> Adobe(R)AIR(TM)
> software. With Adobe AIR, Ajax developers can use existing skills and code
> to
> build responsive, highly engaging applications that combine the power of
> local
> resources and data with the reach of the web. Download the Adobe AIR SDK
> and
> Ajax docs to start building applications
> today-http://p.sf.net/sfu/adobe-com
> _______________________________________________
> Sdcc-user mailing list
> Sdcc-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sdcc-user
>
>


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to