CA65 noob question

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
surfRJ
Posts: 2
Joined: Wed Mar 15, 2023 12:09 am

CA65 noob question

Post by surfRJ »

Is it possible to create a second assembly file with some .proc and call them in the main one by including the file? (like a macro)
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: CA65 noob question

Post by dougeff »

.proc is a way to limit the scope (and reduce errors caused by duplicate label names). Generally, labels defined inside the .proc will not be known to anything outside of the .proc scope.

However, you can do this with 2 colons.

proc-name::label

like

LDA Car::Toyota

I don't know about using it within a macro, but it should be possible.
nesdoug.com -- blog/tutorial on programming for the NES
wendelscardua
Posts: 20
Joined: Fri Jun 26, 2020 2:57 am
Contact:

Re: CA65 noob question

Post by wendelscardua »

surfRJ wrote: Wed Mar 29, 2023 6:07 am Is it possible to create a second assembly file with some .proc and call them in the main one by including the file? (like a macro)
You can include one file on another using .include.

There's also a more complex alternative (which I tend to do) is this: each assembly file .exports the procs they want to be available elsewhere; each assembly file which wants to use a proc from somewhere else .imports it. Then, compile each file separately with ca65 and link them into the final rom with ld65.
Post Reply