Re: [cc65] .global vs .export vs what i really need :)

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2009-10-25 21:38:05
Hi!

On Sat, Oct 24, 2009 at 11:22:25PM +0200, Groepaz wrote:
> ok well then.... its probably a bug in the assembler =)

No, it's not a bug, it's a feature :-)

.proc starts a scope, so the symbols within .proc/.endproc are local to the
new scope. Using explicit scope specification with :: does not handle forward
references, because scopes are different from symbols (see
http://www.cc65.org/doc/ca65-7.html#ss7.4).

The solution is probably simple: Don't use scopes. The names of your symbols
seem to be choosen to be distinct anyway, so there's no real need to enclose
each one in it's own scope. Your example without scopes:

easyprog_opt_s0139:
	sta	X00XL00F4X00X
	stx	X00XL00F4X00X+$01
	rts

X00X_loadEAPIX00X:
	.segment	"BSS"
X00XL00F3X00X:
	.res	$01,$00
X00XL00F4X00X:
	.res	$02,$00
	.segment	"CODE"
	lda	#$01

If you want to make sure that the symbols don't collide with anything in the
user program, just enclose your code into one big scope:

        .scope  glopt65

easyprog_opt_s0139:
	sta	X00XL00F4X00X
	stx	X00XL00F4X00X+$01
	rts

X00X_loadEAPIX00X:
	.segment	"BSS"
X00XL00F3X00X:
	.res	$01,$00
X00XL00F4X00X:
	.res	$02,$00
	.segment	"CODE"
	lda	#$01

        .endscope

Jumps to glopt65 code within user code must then prefixed by glopt65::, but
this is probably no major hurdle.

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 Sun Oct 25 21:39:41 2009

This archive was generated by hypermail 2.1.8 : 2009-10-25 21:39:44 CET