It is currently Mon Dec 17, 2018 6:04 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: CA65 .global and .procs
PostPosted: Thu Feb 11, 2016 5:47 pm 
Offline
User avatar

Joined: Mon Dec 07, 2009 11:08 am
Posts: 95
Location: USA
From what I have read in these forums and in the CA65 docs, I would think that this would work (a snippet of generated code):

Code:
; generated 2016-02-11T16:32:59-08:00

.PROC snake
   .global test
   init:
      jsr test::method

      rts

   update:
      
      rts

   destroy:
      
      rts
.ENDPROC

.PROC test
   method:
      rts
.ENDPROC


However, it does not and I get the following output:

Code:
 ca65 .\src\main.s -g -l .\bin\main.ls -o .\bin\main.o -D DEBUG=1

.\src/scenes/../../bin/gen/..\./objects/SNAKE.s(6): Error: No such scope: `test'
.\src/scenes/../../bin/gen/..\./objects/SNAKE.s(6): Error: Unexpected trailing garbage characters


Any suggestions? Does anything look wrong?


Top
 Profile  
 
PostPosted: Thu Feb 11, 2016 6:31 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 11013
Location: Rio de Janeiro - Brazil
AFAIK, you can't reference scopes that haven't been defined yet.

EDIT: The only way I found to get around this is to use fake scoping, creating labels for anything I want to make visible AFTER the scope is closed, like this:

Code:
.proc test
  method:
.endproc

test_method = test::method

Then I can reference test_method anywhere, even before the "test" scope is created.

EDIT 2: BTW, .global has nothing to do with scopes, its purpose is to import end export symbols between sources that are assembled separately.


Top
 Profile  
 
PostPosted: Thu Feb 11, 2016 9:02 pm 
Offline
User avatar

Joined: Mon Dec 07, 2009 11:08 am
Posts: 95
Location: USA
Thanks tokumaru! The workaround works great.


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 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:  
Powered by phpBB® Forum Software © phpBB Group