6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Oct 05, 2024 6:32 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Tue Feb 04, 2020 11:52 am 
Offline

Joined: Tue Feb 04, 2020 11:46 am
Posts: 4
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:
  ; test.a
  !to "test", plain
  !cpu 65c02

  * = $8000

  !src "lib.a"

reset
  jmp a

  * = $fffc
  !word reset
  !word $0


Code:
  ; 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.

Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 05, 2020 2:17 am 
Offline

Joined: Tue Feb 04, 2020 11:46 am
Posts: 4
Here's the error I get:

Code:
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.


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 05, 2020 2:48 am 
Offline

Joined: Tue Feb 04, 2020 11:46 am
Posts: 4
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.


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 05, 2020 2:57 am 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
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


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 05, 2020 9:34 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10949
Location: England
Yes, indeed, welcome! I wasn't able to help with this one so I didn't jump in to welcome you...


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 06, 2020 3:01 am 
Offline

Joined: Tue Feb 04, 2020 11:46 am
Posts: 4
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: