Thanks.  I believe I set the _XPAGE equal to the CY7C68013's MPAGE SFR after I already wrote my own initialization routine.  I'm currently returning a value so that the sdcc's initialization gets skipped.  That helps explain why my XDATA, globals, and static variables were not being set.  If I have time to go back I'll try it again.  For now we are using XDATA global variables instead of local static variables.  Then we specifically initializing them as main starts.  

I impressed myself yesterday by writing and using a function that returns a pointer to a structure to eliminate an external reference to a global struct:).  Someday maybe someone will declare my code kosher instead of hacked...

Thanks again.  sdcc is working out awesome.  (V2.9.2, up to 7K of code starting with <4K conversion from Keil to sdcc in about 4 weeks, running under DOS CMD Window on WinXP).

From: "Maarten Brock" <>
Date: 10/29/2009 03:39 PM
Subject: [Sdcc-user] [Fwd: Re: Fw: Support for C99 designated initializers?]

Forwarded message follows


All global and static variables in xdata are initialized by crtxinit.asm.
This piece uses DPTR to read code memory and MOVX @Ri and _XPAGE to write
xdata memory. Afterwards _XPAGE is set to the start of pdata. Paged memory
(pdata) is 256 bytes or less, SDCC does not use _XPAGE after


> Maarten;
> Thanks for the reply.  I'm more of a hacker than a programmer.  It still
> isn't obvious to me after reading section 4.1.1.
> The Cypress manuals shows the MPAGE register within the CY7C68013 is only
> used for Upper Addr Byte of MOVX using @R0 / @R1.  I wasn't certain that
> the compiler would work or initialize variables or stop paging external
> memory just by redefining _XPAGE.  I do initialize the MPAGE register just
> in case the instruction is used.  But I didn't need to specify paged
> memory locations as the part has 16K built in and the EZ-USB development
> board has 64K of external memory too.  I don't plan on running out.
> I also couldn't tell how the compiler decides how large the paged memory
> is?  It looks like we have to track memory usage if we're using paged
> memory to guarantee that we stay within the physical limits.
> Here's section 4.1.1 from V2.9.2.  I do redefine _XPAGE to 0x92 just in
> case.  Then if the compiler does invoke a paged memory access it wouldn't
> corrupt P2 which is mapped to IOC (0xA0) of the CY7C68013.  I had tested
> for paging by decompiling the hex code and searching for P2 in the output
> listing prior to redefining _XPAGE.
> SDCCMan.pdf V2.9.2 Section 4.1.1 for reference...
> Kurt M. Sanger
> From:
> "Maarten Brock" <>
> To:
> Date:
> 10/28/2009 03:46 PM
> Subject:
> Re: [Sdcc-user] Fw:  Support for C99 designated initializers?
> Kurt,
> If you had read 4.1.1 too, you would have realized that
> it was enough to declare _XPAGE as an alias for MPAGE to
> make xdata initialization work. And it probably saves a
> lot of code memory.
> Maarten
>> Brandon;
>> In this case I would try initializing your structure within your main
>> startup.  If that works, then the compiler recognizes structures and its
>> just an issue of writing the startup code you need to initialize your
>> variables. (Section 3.12 Startup Code of sdccman.pdf)  I'm writing for
> an
>> 8051 embedded within a Cypress CY7C68013 IC.  I found I needed to write
> my
>> own startup function, and in it I initialize xdata variables.  I didn't
>> rewrite sections to initialize other data types such as idata, byte
> data,
>> and registers.  I have to remember to use global variables and
> initialize
>> them in order to guarantee that they are setup properly.  For instance I
>> had a local static variable that wasn't getting initialized too.
>> Kurt M. Sanger
>> ----- Forwarded by Kurt M. Sanger/241870/EKC on 10/27/2009 01:09 PM
> -----
>> From:
>> Brandon Fosdick <>
>> To:
>> sdcc-user <>
>> Date:
>> 10/27/2009 12:15 AM
>> Subject:
>> [Sdcc-user] Support for C99 designated initializers?
>> I tried to do something like
>> struct {int a, b;} mystruct = { .a=1, .b=1 };
>> and it didn't work, even though I used the --std-c99 option. Did I do
>> something wrong or is this unsupported?
>> The error message was:
>> ../main.c:38: syntax error: token -> '.' ; column 33

Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
Sdcc-user mailing list