Hi Antonio, Are you targeting MCS51 / 8051? Have you tried the __code directive? Cheers, Henry
On Sun, Jun 9, 2013 at 2:58 PM, Antonio Todo Bom <anto...@boole.com.br> wrote: > Hi dears, > > I'm trying to code a table to access strings. My target is produce a routine > to print menus in dual language. > > I wrote: > > const char *menu_str[][] = { > { "text1 lang1", "text1 lang2" }, > { "text2 lang1", "text2 lang2" }, > { "textN lang1", "textN lang2" }, > { 0,0 } > }; > > results: > idata > _menu_str db LOW(__str_0), HIGH(__str_0), UPPER(__str_0), LOW(__str_1), > HIGH(__str_1), UPPER(__str_1), LOW(__str_2), HIGH(__str_2), UPPER(__str_2), > LOW(__str_3), HIGH(__str_3), UPPER(__str_3) > db LOW(__str_4), HIGH(__str_4), UPPER(__str_4), LOW(__str_5), HIGH(__str_5), > UPPER(__str_5), 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 > > ;-------------------------------------------------------- > ; global & static initialisations > ;-------------------------------------------------------- > ; I code from now on! > ; ; Starting pCode block > __str_0: > DB 0x74, 0x65, 0x78, 0x74, 0x31, 0x20, 0x6c, 0x61, 0x6e, 0x67, 0x31, 0x00 > ; ; Starting pCode block > __str_1: > DB 0x74, 0x65, 0x78, 0x74, 0x31, 0x20, 0x6c, 0x61, 0x6e, 0x67, 0x32, 0x00 > ; ; Starting pCode block > __str_2: > DB 0x74, 0x65, 0x78, 0x74, 0x32, 0x20, 0x6c, 0x61, 0x6e, 0x67, 0x31, 0x00 > ; ; Starting pCode block > __str_3: > DB 0x74, 0x65, 0x78, 0x74, 0x32, 0x20, 0x6c, 0x61, 0x6e, 0x67, 0x32, 0x00 > ; ; Starting pCode block > __str_4: > DB 0x74, 0x65, 0x78, 0x74, 0x4e, 0x20, 0x6c, 0x61, 0x6e, 0x67, 0x31, 0x00 > ; ; Starting pCode block > __str_5: > DB 0x74, 0x65, 0x78, 0x74, 0x4e, 0x20, 0x6c, 0x61, 0x6e, 0x67, 0x32, 0x00 > > I'd like to know if is there any way to produce not a idata, but a CODE > sector to _menu_str constant, once all strings are constants and the table > to access it is a constant too, and I don't need to expend RAM memory to > this. > > I did some alternate code to produce what I want: > > const char menu_000 [] = "text1 lang1"; > const char menu_001 [] = "text1 lang2"; > const char menu_010 [] = "text2 lang1"; > const char menu_011 [] = "text2 lang2"; > const char menu_020 [] = "textN lang1"; > const char menu_021 [] = "textN lang2"; > > > void menu_str(void) __naked { > __asm > DW _menu_000, _menu_001 > DW _menu_010, _menu_011 > DW _menu_020, _menu_021 > DW 0, 0 > __endasm; > } > > so, it results exactly I want: > > S_config__menu_str code > _menu_str: > DW _menu_000, _menu_001 > DW _menu_010, _menu_011 > DW _menu_020, _menu_021 > DW _menu_090, _menu_091 > DW 0, 0 > ; ; Starting pCode block for Ival > code > __menu_000: > DB 0x74, 0x65, 0x78, 0x74, 0x31, 0x20, 0x6c, 0x61, 0x6e, 0x67, 0x31, 0x00 > ; ; Starting pCode block for Ival > __menu_001: > DB 0x74, 0x65, 0x78, 0x74, 0x31, 0x20, 0x6c, 0x61, 0x6e, 0x67, 0x32, 0x00 > ; ; Starting pCode block for Ival > __menu_010: > DB 0x74, 0x65, 0x78, 0x74, 0x32, 0x20, 0x6c, 0x61, 0x6e, 0x67, 0x31, 0x00 > ; ; Starting pCode block for Ival > __menu_011: > DB 0x74, 0x65, 0x78, 0x74, 0x32, 0x20, 0x6c, 0x61, 0x6e, 0x67, 0x32, 0x00 > ; ; Starting pCode block for Ival > __menu_020: > DB 0x74, 0x65, 0x78, 0x74, 0x4e, 0x20, 0x6c, 0x61, 0x6e, 0x67, 0x31, 0x00 > ; ; Starting pCode block for Ival > __menu_021: > DB 0x74, 0x65, 0x78, 0x74, 0x4e, 0x20, 0x6c, 0x61, 0x6e, 0x67, 0x32, 0x00 > > > Then, at de header file "I Lied" about the symbols, declaring: > > extern const unsigned int menus_strs[5][2]; > > And IT WORKS... ok, but I'd like to this only in C language to future > compatibility. > > Regards, > > Antonio > > ------------------------------------------------------------------------------ > How ServiceNow helps IT people transform IT departments: > 1. A cloud service to automate IT design, transition and operations > 2. Dashboards that offer high-level views of enterprise services > 3. A single system of record for all IT processes > http://p.sf.net/sfu/servicenow-d2d-j > _______________________________________________ > Sdcc-user mailing list > Sdcc-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sdcc-user > ------------------------------------------------------------------------------ How ServiceNow helps IT people transform IT departments: 1. A cloud service to automate IT design, transition and operations 2. Dashboards that offer high-level views of enterprise services 3. A single system of record for all IT processes http://p.sf.net/sfu/servicenow-d2d-j _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user