From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2003-11-03 22:22:14
On Mon, Nov 03, 2003 at 11:02:35PM +0100, Groepaz wrote:
> oh btw....just remembering a little bug in ca65...sth like
>
> foo=7
>
> .proc
> .repeat foo,count
> .byte count+1
> .endrepeat
> .endproc
>
> gives "constant expression expected" for "foo", but
Yes, that's a thing showing up for some time now in several variants. The
problem is always the same: Since a new scope has been opened, the assembler
does not know if the symbol will get redefined later in the same scope. In
other words, it expects something like:
foo = 7
.proc
.repeat foo,count
.byte count+1
.endprepeat
foo = 8
.endproc
I'm currently working on the assembler, but I have no easy idea how to solve
the problem. My first idea, not to allow any forward decls in presence of a
symbol with the same name, like
foo = 7
.proc
.byte foo ; .byte 7
foo = 8
.byte foo ; .byte 8
.endproc
will not work, because forward decls are needed for jump labels. Having
L1: ; <- A
.proc
jmp L1 ; Jumps to A
L1: ; <- B
jmp L1 ; Jumps to B
.endproc
is a very bad idea.
A workaround is to use ::foo: This tells the assembler to use the foo from the
global namespace.
Two possible solutions would be:
1. a second assembler pass, or
2. a rather complex intermediate representation that is translated in real
code later.
For now, you will probably have to live with ::foo or other scoping directives
I'm currently adding.
Regards
Uz
--
Ullrich von Bassewitz uz_at_musoftware.de
----------------------------------------------------------------------
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 : 2003-11-03 22:22:29 CET