Re: [cc65] ca65 question

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2008-01-25 17:26:22
Hi!

On Wed, Jan 23, 2008 at 10:58:57PM +0100, silverdr@inet.com.pl wrote:
> I would like to define a global string constant, that would become
> available in all the source files. The obvious way to do is to put it
> into an include file and include that file into every source. This
> works but is there maybe a better, more elegant solution to this
> problem?

What do you mean with a string constant? If you just want a string in memory
and access it's address or contents then create one module:

-------------------------------------------------------------------------
        .export         mystring

mystring:       .byte   "my string"
-------------------------------------------------------------------------

And in all other modules use

        .import         mystring        ; Import the address

        lda             mystring+1      ; 'm'

        ldx             #<mystring
        ldy             #>mystring      ; Address of mystring

to access it.

You can also use C-like include files (I do that for larger projects). Create
one include file with all exported identifiers, but use ".global" instead of
".export". Then include this file in the module that exports the symbol (but
omit the .export) and also in all files that want to use the symbols. .global
will do an .export if the symbol is defined and an .import otherwise.

The advantage of this approach is that you have some sort of "interface
definition" which is contained in the include file.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Fri Jan 25 17:26:35 2008

This archive was generated by hypermail 2.1.8 : 2008-01-25 17:26:38 CET