6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Nov 14, 2024 5:48 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Help with LD65 linker.
PostPosted: Tue Oct 29, 2013 7:50 am 
Offline

Joined: Mon Apr 16, 2007 6:04 am
Posts: 155
Location: Auckland, New Zealand
OK, I was making good progress with my Orwell machine. I started working on the LOAD/SAVE routines and was setting up my ACIA to handle receiving serial commands using Garth's circular buffer idea from the primer. I am using a 256 byte buffer.

The issue I have is the code no longer links. I get the following error:

Code:
D:\Users\6502\Projects\Orwell basic>ld65 -C orwell_bas.cfg orwell_bas.o -o orwel
l_bas.bin
ld65.exe: Warning: Memory area overflow in `ZP', segment `ZEROPAGE' (124 bytes)
ld65.exe: Error: Cannot generate output due to memory area overflow


The config file I was using is like this:

Code:
MEMORY {
   ZP:         start = $0000, size = $0100, type=rw, define=yes;   
   ROM:      start = $8000, size = $7FFA, type=ro, define=yes, fill=yes, file=%O;
   VECTS:      start = $FFFA, size = $6;
}

SEGMENTS {
   ZEROPAGE:         load = ZP, type = zp;
   CODE:            load = ROM, type = ro;   
   VECTS:            load = VECTS, type = ro;
}


The memory map for the machine is that the zero page stuff is from $0 to $100 (of course). I have my specific variables from $200 to

_________________
My 6502 related blog: http://www.asciimation.co.nz/bb/category/6502-computer


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 29, 2013 8:02 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8540
Location: Southern California
Since you cut off mid-sentence, I can't tell if you tried to put the 256-byte buffer in ZP. Make sure you're putting it (as well as the program) somewhere else in RAM, not below $200.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 29, 2013 8:29 am 
Offline

Joined: Mon Apr 16, 2007 6:04 am
Posts: 155
Location: Auckland, New Zealand
Oh, I didn't mean to post! I actually worked it out just now. I was checking what I was writing and figured out the problem. Well, I got it working. Not sure I fully understand.

The variables I have are from $200 up. Originally they were from $200 to $208. Then when I added in the receive buffer stuff I changed that from $200 to $30B (i.e. 258 bytes more than before). There is a .org in the code to specify the $200 start. The actual code started at $8000.

I think the linker was saying 'hang on a sec bud, you've gone over the 256 byte limit in the ZP'. I guess the linker doesn't know about .orgs so assumed that page was in the ZP segment?

So I added in a new segment.

Code:
MEMORY {
   ZP:         start = $0000, size = $0100, type=rw, define=yes;
   RAM:        start = $0200, size = $010B, type=rw, define=yes;
   ROM:              start = $8000, size = $7FFA, type=ro, define=yes, fill=yes, file=%O;
   VECTS:      start = $FFFA, size = $6;
}

SEGMENTS {
   ZEROPAGE:         load = ZP, type = zp;
   ORWELL:         load = RAM, type = rw, define=yes;
   CODE:         load = ROM, type = ro;   
   VECTS:         load = VECTS, type = ro;
}


That linked fine. But the binary generated had all my code offset by the size of the RAM memory, the $10B bytes.

That was confusing me and was what I was originally going to post about but I worked out in the end the type I am using was wrong. It needs to be type = bss. Doing that works. The documentation for ld65 isn't the easiest to follow!

I think I need to remove all the .orgs from inside the original code and just use segments. Currently .orgs are used inside the ZP to break it up into the sections used by Microsoft Basic. I think having .orgs and using the linker config can be a little confusing!

Sorry for the mis-post!

Simon

_________________
My 6502 related blog: http://www.asciimation.co.nz/bb/category/6502-computer


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

All times are UTC


Who is online

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