From: Mats Andrén (matan325_at_student.liu.se)
Date: 2004-01-12 16:57:43
Hello there!
I just recently started using ca65 and I've been reading the 
ca65-documentation about scopes, local and global labels, and such. As far 
as I have understood, there is no way of simply declaring a label Global 
within a scope? Sometimes, when working with selfmodifying code (for 
optimization purposes) I find it useful to "break" the .scope-hierarchy. 
So, If I have some code like this:
;------------------------------------------------------
; MY EXAMPLE SUBROUTINE, WITH TWO DIFFERENT ENTRYPOINTS
EntrypointA:
.scope
       lda #$xx
       sta dest+1
       lda #$yy
       sta dest+2
       jmp MainFunction
EntrypointB:
       lda #$zz
       sta dest+1
       lda #$ww
       sta dest+2
       jmp MainFunction
MainFunction:
       jsr calculatesomevalue
dest: sta $ffff
       rts
.endscope
;------------------------------------------------------
; MAIN PROGRAM
       ...
       jsr EntrypointA
       jsr EntrypointB
       ...
;------------------------------------------------------
...it does not work out at all, of course, even though I still find this a 
sensible way to structure asm-code in some occasions.
Either I'll have to do one .scope/.endscope-pair for each Entrypoint to 
make EntrypointB being a globally visible lable, wich means I have to use 
some extensive naming scheme to keep track of all the scopes. "dest" would 
then loose it's local scope-"feeling", since I would have to preceed all 
access to it with some specific scope-information (scoopex::dest f.ex.) to 
access it.
..or either I'd have to put all the Entrypoints within a named scope (let's 
say "thisfunction") and access them with scope specific information, like this:
       jsr thisfunction::EntrypointA
       jsr thisfunction::EntrypointB
While it may not look so bad here in my example, it would introduce quite 
some naming overhead into my project (which I am converting right now from 
DASM-sources). The possibility to just declare EntrypointB as Global would 
be so much easier than all that explicit naming stuff. What do you say? Am 
I simply fucked up, or is there actually some sense in this? :) Maybe it is 
actually already possible to do this, only I haven't realized how to do it 
nicely?
I'm using:
ca65 V2.10.0 - (C) Copyright 1998-2003 Ullrich von Bassewitz
That should be 2004 now, right? :)
ca65 rules! Have a nice day!
(Also I have some problems using the BSS-segments, but that's another 
issue. Couldn't really find any code examples using it. Any hints on where 
to look?)
/Autoboy
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2004-01-12 16:58:56 CET