Page 1 of 1
[solved] "Symbol already defined" error with ACME assembler
Posted: Tue Feb 04, 2020 11:52 am
by decitrig
I'm having trouble understanding why I'm getting a "Symbol already defined" error from acme. It seems to happen when I include a .a file that triggers a second assembler pass, but I'm not sure what to do to mitigate the problem. I managed to reproduce the problem with a couple small files:
Code: Select all
; test.a
!to "test", plain
!cpu 65c02
* = $8000
!src "lib.a"
reset
jmp a
* = $fffc
!word reset
!word $0
Code: Select all
; lib.a
!ifdef lib_a !eof
lib_a = 1
a
jmp b ; Triggers a second pass because `b` is not known here
b
jmp a
I tried wrapping the "reset" label in !ifndef reset { ... }, but then the assembler produces an empty file. What am I doing wrong?
(edit): I don't get the same error if I inline the contents of 'lib.a' directly in 'test.a', so it's something about the !src call.
Re: "Symbol already defined" error with ACME assembler
Posted: Wed Feb 05, 2020 2:17 am
by decitrig
Here's the error I get:
Code: Select all
Error - File test.a, line 8 (Zone <untitled>): Symbol already defined.
Line 8 refers to the "reset" label.
If I remove the !ifdef in lib.a, it works fine.
I notice that the libraries in
https://github.com/meonwax/acme/tree/master/ACME_Lib seem to be entirely macros and symbol definitions; maybe putting actual code in !src files isn't supported.
Re: "Symbol already defined" error with ACME assembler
Posted: Wed Feb 05, 2020 2:48 am
by decitrig
Oh I think I get it. On pass 1, the "a" label is at $8000 and ."reset" is at 0x8006. However on pass 2, the "a" label is no longer defined, so it wants to put the "reset" label at $8000, which is redefining it to a different value.
I verified this by moving the !src to *after* the reset block, and it assembles just fine.
This makes sense now that I think about it: if the included file has anything that takes up actual space, it'll move addresses around and so shouldn't be excluded in subsequent passes.
Re: "Symbol already defined" error with ACME assembler
Posted: Wed Feb 05, 2020 2:57 am
by Dr Jefyll
Welcome, decitrig ! Thanks for posting, and I'm glad you got yourself sorted out. Sorry you didn't get a prompt reply, but I hope you'll stick around and get acquainted with the folks here.
cheers
Jeff
Re: "Symbol already defined" error with ACME assembler
Posted: Wed Feb 05, 2020 9:34 am
by BigEd
Yes, indeed, welcome! I wasn't able to help with this one so I didn't jump in to welcome you...
Re: "Symbol already defined" error with ACME assembler
Posted: Thu Feb 06, 2020 3:01 am
by decitrig
Thanks for the welcome! No worries about not catching this, of course; I just wanted to make sure to follow up with the solution not to leave it dangling.