It is currently Thu Aug 16, 2018 1:06 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Mon Jan 15, 2018 1:07 am 
Offline

Joined: Mon May 27, 2013 9:40 am
Posts: 478
I've been having this problem for months. It just seems to be an ugly warning as everything seems to work, but I don't like warnings.

It seems that tschak909 had the same problem here: viewtopic.php?p=211844#p211844 and got it sorted out, but the same solution doesn't work for me.

This is my issue:

I created a couple of pointers in ZP in the crt0 file. They are read by a modification I made to neslib, and have to be written from by C code in my main module. Such pointers are defined as:

Code:
.export _SCROLL_WRITE, _ATTRIB_WRITE

[...]

.segment "ZEROPAGE"

; [...] <- neslib stuff being defined here as in lots of "var .res N"

_SCROLL_WRITE:    .res 2
_ATTRIB_WRITE:    .res 2


Those symbols I import from my main module:
Code:
extern unsigned char *SCROLL_WRITE;
#pragma zpsym ("SCROLL_WRITE")
extern unsigned char *ATTRIB_WRITE;
#pragma zpsym ("ATTRIB_WRITE")


But keep getting the warnings:

Code:
ld65: Warning: Address size mismatch for `_ATTRIB_WRITE': Exported from crt0.o, crt0-pantanow.s(81) as `zeropage', import in game.o, game.s(20597) as `absolute'
ld65: Warning: Address size mismatch for `_SCROLL_WRITE': Exported from crt0.o, crt0-pantanow.s(80) as `zeropage', import in game.o, game.s(20597) as `absolute'


I even updated to the latest win32 snapshot of cc65, to no avail. Any pointers on what I'm doing wrong / what's missing?

Thanks.

_________________
http://www.mojontwins.com


Top
 Profile  
 
PostPosted: Mon Jan 15, 2018 3:17 am 
Offline
User avatar

Joined: Sat Sep 07, 2013 2:59 pm
Posts: 1662
The error message doesn't seem to imply this, but shouldn't it be .exportzp in the Assembly file instead of .export?

_________________
Available now: My game "City Trouble".
Website: https://megacatstudios.com/products/city-trouble
Trailer: https://youtu.be/IYXpP59qSxA
Gameplay: https://youtu.be/Eee0yurkIW4
German Retro Gamer article: http://i67.tinypic.com/345o108.jpg


Top
 Profile  
 
PostPosted: Mon Jan 15, 2018 3:44 am 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 778
Either the warning is wrong, or your crt0.s has another .section directive in between, causing them to be normal symbols. I use ZP symbols all the time, and don't have any warnings.

edit: Look at the generated game.s asm. It should have those as importzp, not import.


Top
 Profile  
 
PostPosted: Mon Jan 15, 2018 2:57 pm 
Offline

Joined: Mon May 27, 2013 9:40 am
Posts: 478
Thanks both. I'll double-check.

_________________
http://www.mojontwins.com


Top
 Profile  
 
PostPosted: Fri Apr 27, 2018 11:23 am 
Offline

Joined: Mon May 27, 2013 9:40 am
Posts: 478
Sorry for necromancing my own thread, but I forgot, time passed, and I didn't actually check what I was supposed to check. Anyways.

1.- There's absolutely not a different .section directive going in between:

Code:
.segment "ZEROPAGE"

NTSC_MODE:          .res 1
FRAME_CNT1:       .res 1
FRAME_CNT2:       .res 1
VRAM_UPDATE:       .res 1
NAME_UPD_ADR:       .res 2
PAL_UPDATE:       .res 1
PAL_BG_PTR:       .res 2
PAL_SPR_PTR:       .res 2
SCROLL_X:          .res 1
SCROLL_Y:          .res 1
SCROLL_X1:          .res 1
SCROLL_Y1:          .res 1
PAD_STATE:          .res 2      ;one byte per controller
PAD_STATEP:       .res 2
PAD_STATET:       .res 2
PPU_CTRL_VAR:       .res 1
PPU_CTRL_VAR1:       .res 1
PPU_MASK_VAR:       .res 1
RAND_SEED:          .res 2
FT_TEMP:          .res 3
_SCROLL_WRITE:      .res 2       ; <----
_ATTRIB_WRITE:       .res 2       ; <----
[... etc]


2.- The generated .s file doesn't have an import for _SCROLL_WRITE or _ATTRIB_WRITE. In fact, I am not using the pointers in C code, but in inline assembly within a C function:

Code:
void scroll_writers_realloc (void) {
   if (wtp) wtp --; else wtp = 59;
   if (wtp < 30) {
      wtpr = wtp;
      __asm__ ("ldx _wtpr");
      __asm__ ("lda _shl5_hi, x");
      __asm__ ("clc");
      __asm__ ("adc #$20");
      __asm__ ("sta <_SCROLL_WRITE");
      __asm__ ("lda _shl5_lo, x");
      __asm__ ("sta <_SCROLL_WRITE+1");
      __asm__ ("lda _shr2, x");
      __asm__ ("tay");
      __asm__ ("lda #$23");
      __asm__ ("sta <_ATTRIB_WRITE");
      __asm__ ("lda _attrs_adds, y");
      __asm__ ("sta <_ATTRIB_WRITE+1");
   } else {
      wtpr = wtp - 30;
      __asm__ ("ldx _wtpr");
      __asm__ ("lda _shl5_hi, x");
      __asm__ ("clc");
      __asm__ ("adc #$28");
      __asm__ ("sta <_SCROLL_WRITE");
      __asm__ ("lda _shl5_lo, x");
      __asm__ ("sta <_SCROLL_WRITE+1");
      __asm__ ("lda _shr2, x");
      __asm__ ("tay");
      __asm__ ("lda #$2B");
      __asm__ ("sta <_ATTRIB_WRITE");
      __asm__ ("lda _attrs_adds, y");
      __asm__ ("sta <_ATTRIB_WRITE+1");
   }
}


I guess that's the real problem (by the way, game.c compiles without the extern definitions I mentioned in the OP). Any ideas to get rid of the warning?

Code:
ld65: Warning: Address size mismatch for `_ATTRIB_WRITE': Exported from crt0.o, crt0-pantanow.s(81) as `zeropage', import in game.o, game.s(20740) as `absolute' ld65: Warning: Address size mismatch for `_SCROLL_WRITE': Exported from crt0.o, crt0-pantanow.s(80) as `zeropage', import in game.o, game.s(20740) as `absolute'


The most interesting part is that 20740 lines is exactly the size of the generated game.s file.

_________________
http://www.mojontwins.com


Top
 Profile  
 
PostPosted: Fri Apr 27, 2018 12:00 pm 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 778
Well that does make it clear, you're specifying them as inline assembly *text*. Neither the compiler nor assembler know you are accessing them.

Switch to using the inline assembly form where you pass the variable from outside, not via the text.


Top
 Profile  
 
PostPosted: Fri Apr 27, 2018 12:18 pm 
Offline
User avatar

Joined: Sat Jan 09, 2016 9:21 pm
Posts: 445
Location: Central Illinois, USA
calima wrote:
Well that does make it clear, you're specifying them as inline assembly *text*. Neither the compiler nor assembler know you are accessing them.

Switch to using the inline assembly form where you pass the variable from outside, not via the text.


To clarify what that means:

Code:
__asm__ ("sta <%v", ATTRIB_WRITE);


The %v and other format specifiers are defined here https://www.cc65.org/doc/cc65-9.html.

_________________
My games: http://www.bitethechili.com


Top
 Profile  
 
PostPosted: Fri Apr 27, 2018 2:27 pm 
Offline

Joined: Mon May 27, 2013 9:40 am
Posts: 478
Thanks. I usually use the "%v", etc format - but I guess that snippet was coded some time ago when I haven't read the documentation properly.

Now the warning is gone. Thank you for the enlightement. Now the code is written properly

Code:
void scroll_writers_realloc (void) {
   if (wtp) wtp --; else wtp = 59;
   if (wtp < 30) {
      wtpr = wtp;
      __asm__ ("ldx %v", wtpr);
      __asm__ ("lda %v, x", shl5_hi);
      __asm__ ("clc");
      __asm__ ("adc #$20");
      __asm__ ("sta <%v", SCROLL_WRITE);
      __asm__ ("lda %v, x", shl5_lo);
      __asm__ ("sta <%v+1", SCROLL_WRITE);
      __asm__ ("lda %v, x", shr2);
      __asm__ ("tay");
      __asm__ ("lda #$23");
      __asm__ ("sta <%v", ATTRIB_WRITE);
      __asm__ ("lda %v, y", attrs_adds);
      __asm__ ("sta <%v+1", ATTRIB_WRITE);
   } else {
      wtpr = wtp - 30;
      __asm__ ("ldx %v", wtpr);
      __asm__ ("lda %v, x", shl5_hi);
      __asm__ ("clc");
      __asm__ ("adc #$28");
      __asm__ ("sta <%v", SCROLL_WRITE);
      __asm__ ("lda %v, x", shl5_lo);
      __asm__ ("sta <%v+1", SCROLL_WRITE);
      __asm__ ("lda %v, x", shr2);
      __asm__ ("tay");
      __asm__ ("lda #$2B");
      __asm__ ("sta <%v", ATTRIB_WRITE);
      __asm__ ("lda %v, y", attrs_adds);
      __asm__ ("sta <%v+1", ATTRIB_WRITE);
   }
}

_________________
http://www.mojontwins.com


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 5 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