Hi. I am trying to segregate code and data into loadable blocks that can be loaded into banked (and non-banked) RAM. The standard loadable image is supposed to be one .com file that loads at $8000. The other chunks are intended to be written by the linker into xxxx.bnk files that can be loaded at run time by a loader contained in the .com file segment. The config file I am using can be seen at the end of the message. At runtime, the normal .com file gets loaded, and then it runs a bank loader program that loads the mainbank.bnk file into memory at $4000. My question relates to the read-only-data segment. I find if I have a definition like : #pragma codeseg ("MAINSEG") #pragma dataseg ("MAINDAT") #pragma rodataseg("MAINROD") #pragma bssseg ("MAINBSS") char * test( void ) { return "hi there"; } The address returned for the literal in the return statement is not correct. I can see ( in a hex editor ) that the literal is embedded into the mainbank.bnk file, but not at the address that gets returned by the function. It seems like the program counter gets off or is not incremented when a rodataseg is emitted? I am very sure that the loader function is loading the mainbank.bnk file at the correct address and is loading all of it. A dump of memory after the load looks exactly like the mainbank.bnk file on disk. If I omit the rodataseg pragma, then the literal gets generated into the primary .com image and the function returns the correct address for the literal. I am aware that there is an example of handling a memory hole for banked ram in the docs, but that is not quite what I am trying to do. So, am I not understanding something about the way the rodataseg gets handled or is it something else? ------------------------------------------------------------------------ ------------------------------------------------------------------------ -------- FEATURES { STARTADDRESS: default = $8000; } SYMBOLS { __STACKSIZE__ = $200; # 512b parm stack __RESERVED_MEMORY__: value = $1, weak = yes; } MEMORY { ZP: start = $0082, size = $007E, type = rw, define = yes; HEADER: start = $0000, size = $0006, file = %O; RAM: start = %S , size = $BC20 - __STACKSIZE__ - %S, define=yes, file = %O; TRAILER: start = $0000, size = $0006, file = %O; BANK0: start = $4000, size = $4000, define=yes, file = "bank0.bnk"; BANK1: start = $4000, size = $4000, define=yes, file = "bank1.bnk"; BANK2: start = $4000, size = $4000, define=yes, file = "bank2.bnk"; BANK3: start = $4000, size = $4000, define=yes, file = "bank3.bnk"; MAINBANK:start = $4000, size = $4000, define=yes, file = "mainbank.bnk"; DATAMEM: start = $2000, size = $2000, define=yes, file = "databank.bnk"; } SEGMENTS { EXEHDR: load = HEADER, type = ro; LOWCODE: load = RAM, type = ro, define = yes, optional = yes; INIT: load = RAM, type = ro, define = yes, optional = yes; CODE: load = RAM, type = ro, define = yes; RODATA: load = RAM, type = ro, define = yes; DATA: load = RAM, type = rw, define = yes; BSS: load = RAM, type = bss,define = yes; HEAP: load = RAM, type = bss, optional = yes; # must sit just below stack ZEROPAGE: load = ZP, type = zp; EXTZP: load = ZP, type = zp, optional = yes; AUTOSTRT: load = TRAILER, type = ro; DATASEG : load = DATAMEM, type = ro, define=yes, optional = yes; DATADAT : load = DATAMEM, type = rw, define=yes, optional = yes; DATAROD : load = DATAMEM, type = ro, define=yes, optional = yes; DATABSS : load = DATAMEM, type = bss, define=yes, optional = yes; MAINSEG: load = MAINBANK, type = ro, define=yes, optional = yes; MAINDAT: load = MAINBANK, type = rw, define=yes, optional = yes; MAINBSS: load = MAINBANK, type = bss, define=yes, optional = yes; MAINROD: load = MAINBANK, type = ro, define=yes, optional = yes; BANK0DAT: load = BANK0, type = rw, define=yes, optional = yes; BANK0BSS: load = BANK0, type = bss, define=yes, optional = yes; BANK0SEG: load = BANK0, type = ro, define=yes, optional = yes; BANK0ROD: load = BANK0, type = ro, define=yes, optional = yes; BANK1DAT: load = BANK1, type = rw, define=yes, optional = yes; BANK1BSS: load = BANK1, type = bss, define=yes, optional = yes; BANK1SEG: load = BANK1, type = ro, define=yes, optional = yes; BANK1ROD: load = BANK1, type = ro, define=yes, optional = yes; BANK2DAT: load = BANK2, type = rw, define=yes, optional = yes; BANK2BSS: load = BANK2, type = bss, define=yes, optional = yes; BANK2SEG: load = BANK2, type = ro, define=yes, optional = yes; BANK2ROD: load = BANK2, type = ro, define=yes, optional = yes; BANK3DAT: load = BANK3, type = rw, define=yes, optional = yes; BANK3BSS: load = BANK3, type = bss, define=yes, optional = yes; BANK3SEG: load = BANK3, type = ro, define=yes, optional = yes; BANK3ROD: load = BANK3, type = ro, define=yes, optional = yes; } FEATURES { CONDES: segment = INIT, type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__; CONDES: segment = RODATA, type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__; CONDES: type = interruptor, segment = RODATA, label = __INTERRUPTOR_TABLE__, count = __INTERRUPTOR_COUNT__; } Dan Winslow ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo@musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.Received on Thu Mar 26 16:43:32 2009
This archive was generated by hypermail 2.1.8 : 2009-03-26 16:43:34 CET