Re: [cc65] Export symbols out of 'proc'-scope to file scope?

From: Ullrich von Bassewitz <>
Date: 2010-01-30 19:06:58

On Sat, Jan 30, 2010 at 02:01:38PM +0100, Christian Krüger wrote:
> Is there a way to make a forward declaration so that I can refer to a scope
> which follows?

No, sorry. This introduces all sorts of weird problems, so I've decided
against it.

> ATM I just rely on my 'SMC_' labels, which requires some discipline.

The snapshot version allows to introduce new symbols into existing scopes, so
you can use a separate scope for this, instead of relying on a prefix.

> If the assembler would provide some support, sources of error could
> be reduced:

The general rule for self modifying code is: Don't do it. I admit that there
are problems that are difficult to solve on the 6502, so even the library
contains a few lines of self modifying code. But these few lines are
manageable. I'm not going to change ca65 into a development platform for self
modifying code, since I want to discourage people doing it, not encourage

> * the change position is clear, a addressing error like SMC_Value =
> *-1 or SMC_Value = *-2
>  could not happen
> * use would be easier and less error-prone with something like
> SMC_Opcode, SMC_Byte, SMC_Word
> * code is better understandable and SMC use is pointed out / clear
> * additional logic could check if SM-Code ( ;-) ) is used in
> read-only segments, which forces
>  an error

Why not use a set of macros as I've suggested in my last post? You can pass
opcodes to a macro, so this should be doable and doesn't require changes to
ca65. Here is a very simplified example:

.macro  smc     opcode, label, arg
label   := *+1
        opcode  arg

        ; Code that is going to get modified
        smc     lda, $1234

        ; Patch the argument
        lda     #$20
        sta     foo
You can do all sorts of checks within the macro, for example check the size of
the argument.

> BTW: Any news regarding the CMI08 assembly?

I've built it over the christmas days, but it's still untested. I will have to
unpack one of my C64 to do the final test. But instructions were very clear so
it wasn't difficult to build. I'll drop you a mail, when I did the final test.



Ullrich von Bassewitz                        
To unsubscribe from the list send mail to with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sat Jan 30 19:07:07 2010

This archive was generated by hypermail 2.1.8 : 2010-01-30 19:07:09 CET