Re: [cc65] Passing variables from asm to c and vice versa

From: Groepaz <groepaz1gmx.net>
Date: 2008-08-05 21:59:42
On Dienstag 05 August 2008, Ullrich von Bassewitz wrote:
> Hi!
>
> On Tue, Aug 05, 2008 at 10:56:45AM +0200, Stefan wrote:
> > But if i calculate the difference of two constant pointers they are for
> > some reason not recognized as constants (A difference of constants is
> > again constant, or?).
> > The same i get, when i define a label _colortable_size in the assembler
> > program.
> > This is again not recognized as contant in the c code even with the
> > ampersand before.
>
> No compiler known to me does what you want, so you have to find other
> solutions. Compiling the following code
>
>     int main (void)
>     {
>         extern unsigned char colortable[];
>         extern unsigned char colortable_end[];
>
>         static unsigned char colorindex = colortable_end-colortable-1;
>         return 0;
>     }
>
> this is what cc65 says:
>
>     uz@trixie:~$ cc65 test.c
>     test.c(6): Error: Constant expression expected
>
> this is what gcc says:
>
>     uz@trixie:~$ gcc  test.c
>     test.c: In function ‘main’:
>     test.c:6: error: initializer element is not computable at load time
>
> and finally this is what Watcom C says:
>
>     uz@trixie:~$ wine wcc386 -oneatx -zq test.c
>     test.c(6): Error! E1054: Expression must be constant


eeeeeh did you actually link a proper second file that has these pointers?

i am using a similar (almost exactly the same) construct to include all my 
binary data in dozens of projects, all compiled with gcc :)

when you convert a binary to object using objcopy, it will generate such 
pointers, and the proposed method to use these objects is just like what's 
beeing done here :)

or i am missing something =P

-- 

http://www.hitmen-console.org
http://www.pokefinder.org
http://ftp.pokefinder.org

Fortschritt ist wie eine Horde Schweine. Beides hat viel Gutes, aber man darf 
sich nicht wundern, dass alles voller Scheisse ist.

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Aug 5 21:58:57 2008

This archive was generated by hypermail 2.1.8 : 2008-08-05 21:58:59 CEST