This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

CA65 import labels without using additional space

CA65 import labels without using additional space
by on (#242721)
Hey guys, I decided to take up trying to understand the low levels of NesDev, and although I know a good majority of the users use ASM6, I decided to take a stab at CA65 just to see if I can get an understanding of it.

In my project, I decided to break up all of my segments into separate files.

My segment looks like this:

Code:
.import reset ,nmi ,irq
.segment "VECTORS"
.word nmi
.word reset
.word irq


where reset, nmi, and irq are labels in separate files.

This is causing the error that my Vectors segment is 6 bytes over.

Now Vectors is only suppose to be 6 bytes, since all it does is store the address to 3 different parts of the program.

I think I know the why, because import increasing the size of vectors by 6? I am assuming it is because the addresses are being stored twice in the file.

Which brings me to my question. How do I get the compiler to import labels from other files without adding to the file size?

I would like to do this throughout all my work, so it will not be isolated to this incident, and reserving bytes for the labels is just not ideal.

Any help in trying to understand this would be appreciated, thank you in advance.
Re: CA65 import labels without using additional space
by on (#242722)
.import does not impact the size of generated data. All it does is make a symbol available for use, it doesn't add any data to any segment.

My guess is that you have accidentally defined your vector table twice. Maybe search your code for another use of .segment "VECTORS"? Another possibility is that you have code just below it and forgot to change segment afterward?
Re: CA65 import labels without using additional space
by on (#242723)
That was what I was thinking at first.

There is no code below it, that is the entire file.


I do not know why I did not check before, but I should have just did this:

Code:
.segment "VECTORS"
.word 0
.word 0
.word 0



To test it out.

I think what is happening is vectors.s is getting included twice since this is the only spot that has .segment Vectors.

I will investigate more into this, thanks for at least giving me some clarity for what is going on.
Re: CA65 import labels without using additional space
by on (#242734)
If you do not have your own crt0.s, the system's is used.
Re: CA65 import labels without using additional space
by on (#242735)
I removed everything related to linking neslib libraries from the CA65 builds, so it will not use anything outside of my project.


I am currently doing this on a custom fork of the 8bitworkshop.


I finally got it working, the project was implicitly linking vector.s as well as explicitly linking it. I just needed to commit to git and bring it back down to remove the implicit linking.

Thank you everybody.
Re: CA65 import labels without using additional space
by on (#242838)
I do not have auto import on, and I am not sure why you are saying it will not emit any code when it is going to place the 3 addresses at the locations specified in the config file ($7FFA, $7FFC, $7FFE).

This topic can be closed, the issue was with the IDE I was using, nothing more.
Re: CA65 import labels without using additional space
by on (#242846)
knight0fdragon wrote:
I do not have auto import on, and I am not sure why you are saying it will not emit any code when it is going to place the 3 addresses at the locations specified in the config file ($7FFA, $7FFC, $7FFE).

The message you were replying to got deleted, apparently on suspicion of it being bot-generated (it looked like it just copy/pasted the first 3 Google search results it found).