-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import/export of zeropage symbols using pragmas in C does not work as expected #261
Comments
Earlier discussion (for people who were not involved): http://sourceforge.net/p/cc65/mailman/message/34776608/ IMO it's still more of a limitation rather than a bug, though. That said, it would be good to see the |
I agree with "fo-fo". Uz said that we are supposed to create the variables in Assembly files; then, link and use them in C files. We aren't blocked from using our own zero-page variables in C code; we just cannot do it with pure C and most of the supplied configurations. This reminds me about a complaint that I have about Uz's design: the compiler steals |
i dont agree, its equally ugly and just hiding the actual problem (which is that the name of the actual zeropage segment is hardcoded into the assembler). and... wouldnt that require to hardcode that CC65REGS segment the same way? yuck |
Some of the supplied configurations already have several zero-page segments (look at "lynx.cfg"). "CC65REGS" would be another one of them. It always would be first in the list (so that dynamically-loaded modules can find the pseudo-registers). But other than that, it would be like all of the other zero-page segments. It doesn't need to be hardcoded (the others aren't hardcoded). The The "sticking point" is that it wouldn't be backward-compatible with people's existing projects that have their own configuration files -- users would be forced.to edit those files before they could build those projects. I agree that we would have a problem if we wanted our pure C project to spread its zero-page variables among several different segments -- currently, it can't be done without the warning message. |
@oliverschmidt #1282 did not fix this issue. Exporting definitions as zeropage works but importing extern declarations does not. #pragma bss-name (push, "ZEROPAGE")
extern char foo;
#pragma bss-name (pop)
void bar() {
++foo;
} Compiles to: ;
; File generated by cc65 v 2.19 - Git ce3bcad
;
.fopt compiler,"cc65 v 2.19 - Git ce3bcad"
.setcpu "6502"
.smart on
.autoimport on
.case on
.debuginfo off
.importzp sp, sreg, regsave, regbank
.importzp tmp1, tmp2, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4
.macpack longbranch
.import _foo ; <<<<<<<< This should be .importzp <<<<<<<<<<
.export _bar
; ---------------------------------------------------------------
; void __near__ bar (void)
; ---------------------------------------------------------------
.segment "CODE"
.proc _bar: near
.segment "CODE"
ldx #$00
inc _foo
lda _foo
rts
.endproc |
@cogwheel: I'm not maintaining cc65 anymore. It's not useful to mention me in comments. |
what i did was exporting a symbol in one C file, using pragmas to make it a zeropage symbol and also pushing it into a custom segment. and then i import it in another file, again using pragma to make it a zeropage symbol (as described in the docs):
now the odd thing is, the assembler gives this warning:
...which seems wrong (and is a bit irritating). also the generated code is correct (uses zeropage adressing).
whats interesting is that the warning goes away when putting the symbol into the regular "ZEROPAGE" segment (without changing anything else) - that seems to imply that its actually a bug, because for extra zeropage variables using an extra segment is pretty much required.
The text was updated successfully, but these errors were encountered: