[solved] "Symbol already defined" error with ACME assembler

Programming the 6502 microprocessor and its relatives in assembly and other languages.
Post Reply
decitrig
Posts: 4
Joined: 04 Feb 2020

[solved] "Symbol already defined" error with ACME assembler

Post 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.
Last edited by decitrig on Thu Feb 06, 2020 3:01 am, edited 1 time in total.
decitrig
Posts: 4
Joined: 04 Feb 2020

Re: "Symbol already defined" error with ACME assembler

Post 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.
decitrig
Posts: 4
Joined: 04 Feb 2020

Re: "Symbol already defined" error with ACME assembler

Post 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.
User avatar
Dr Jefyll
Posts: 3526
Joined: 11 Dec 2009
Location: Ontario, Canada
Contact:

Re: "Symbol already defined" error with ACME assembler

Post 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
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: "Symbol already defined" error with ACME assembler

Post by BigEd »

Yes, indeed, welcome! I wasn't able to help with this one so I didn't jump in to welcome you...
decitrig
Posts: 4
Joined: 04 Feb 2020

Re: "Symbol already defined" error with ACME assembler

Post 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.
Post Reply