News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Multiple readonly definition in object files.

Started by indiocolifa, September 21, 2005, 09:14:02 PM

Previous topic - Next topic

indiocolifa

My program uses a readonly constant:


READONLY

   opcodeTable : opcode[] := [opcode:["BRK", IMP ,7],      /* $00 */
                              opcode:["ORA", IDXI,6],      /* $01 */
                              opcode:["???", NA ,0],      /* $02 */
                              opcode:["???", NA ,0],      /* $03 */
                              opcode:["???", NA ,0],      /* $04 */
                              opcode:["ORA", ZP , 3]

...


SInce this constant table is needed in many units, the compiled EXE includes the definition of this object many times ... You inspect the EXE with an hex viewer and see the table duplicated in every unit compiled (in fact, every object code compiled..)

How I can make all units to compile with a single main table? The problem is that my EXE grows substantially with every unit that needs this readonly table.

Thank you very much.

Sevag.K

If the data is in your header file, take if out (in fact, don't put any data in the header file).

1st, include the same header file in each unit.
The header should contain an external definition:

readonly
opcodeTable: opcode; @external;


Then, add the data table in only 1 unit (perhaps one reserved only for data).
Now that one data table will be visible in all units.


indiocolifa

Worked like a charm...  :U
Reduced my EXE from 30K to 16K.