From: Ragnar S. <ra...@na...> - 2001-01-13 19:07:46
|
"xdata" should work, since xdata memoru space is initialised with generated code, see example 1 below. I use "code" (for *my* ez-usb project with ported cypress EZUSB framework :-) since it is much more compact - no code is generated, just the data is layed out in the image. Just make even more sure that you don't index beyond boundaries and such, since your data will be surrounded by code, and a bug that accidentally changes code might be really tricky to find. ------------------------------------------------ Example 1: xdata initialization (sdcc ~2.2.2, solaris): c-code: xdata char foo[] = {0x11, 0x22, 0x33, 0x44}; asm: ;-------------------------------------------------------- ; external ram data ;-------------------------------------------------------- .area XSEG (XDATA) G$foo$0$0==. _foo:: .ds 4 ;-------------------------------------------------------- ; global & static initialisations ;-------------------------------------------------------- .area GSINIT (CODE) .area GSFINAL (CODE) .area GSINIT (CODE) ; test2.c 3 mov dptr,#_foo mov a,#0x11 movx @dptr,a mov dptr,#(_foo + 0x0001) mov a,#0x22 movx @dptr,a mov dptr,#(_foo + 0x0002) mov a,#0x33 movx @dptr,a mov dptr,#(_foo + 0x0003) mov a,#0x44 movx @dptr,a ------------------------------------------------ Example 2: code initialization c-code: xdata char foo[] = {0x11, 0x22, 0x33, 0x44}; asm: ;-------------------------------------------------------- ; code ;-------------------------------------------------------- .area CSEG (CODE) .area CSEG (CODE) G$foo$0$0 == . _foo: .db #0x11 .db #0x22 .db #0x33 .db #0x44 ------------------------------------------------ /ragge |