It is currently Thu Apr 26, 2018 10:38 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sat Feb 10, 2018 4:16 pm 
Offline

Joined: Sat Jan 09, 2016 5:30 pm
Posts: 11
What it says on the tin. I dunno how to set up the linker script so it works with multiple banks, each with their own .c file.

What I have is this (it's for a custom 6502-based system with RAM at $0000-$1FFF and $6000-$7FFF):
Code:
MEMORY {
    ZP: start = $00, size = $100, type = rw;
    BSS: start = $200, size = $1E00, type = rw;
    BSS2: start = $6000, size = $2000, type = rw;
    HEADER: start = $0000, size = $10, file = %O;
    BANK0: start = $8000, size = $4000, file = "bank/b0.bin";
    BANK1: start = $8000, size = $4000, file = "bank/b1.bin";
    BANK2: start = $8000, size = $4000, file = "bank/b2.bin";
    BANK3: start = $8000, size = $4000, file = "bank/b3.bin";
    BANK4: start = $8000, size = $4000, file = "bank/b4.bin";
    BANK5: start = $8000, size = $4000, file = "bank/b5.bin";
    BANK6: start = $8000, size = $4000, file = "bank/b6.bin";
    BANK7: start = $8000, size = $4000, file = "bank/b7.bin";
}
SEGMENTS {
    EXEHDR: load = HEADER, type = wprot;
    CODE0: load = BANK0, type = wprot, define = yes;
    CODE1: load = BANK0, type = wprot, define = yes;
    CODE2: load = BANK0, type = wprot, define = yes;
    CODE3: load = BANK0, type = wprot, define = yes;
    CODE4: load = BANK0, type = wprot, define = yes;
    CODE5: load = BANK0, type = wprot, define = yes;
    CODE6: load = BANK0, type = wprot, define = yes;
    CODE7: load = BANK0, type = wprot, define = yes;
    ZEROPAGE: load = ZP, type = zp;
    BSS: load = BSS, type = bss;
    BSS2: load = BSS2, type = bss;
}


Top
 Profile  
 
PostPosted: Sat Feb 10, 2018 4:35 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6229
Location: Canada
Maybe you've already caught this type but those load = should point to BANK1, BANK2, etc.

Make sure the CRT stuff goes in a fixed bank. I'm assuming you're using UxROM style banking? (16k banks $8000, 16k fixed at $C000). Make BANK7 start at $C000, and load CODE + DATA + RODATA segments there. This will be your fixed bank, and the CRT library stuff uses those segments by name already. Don't let your banked C code use those segments.

After that, make sure to use #pragma code-name / data-name / rodata-name in all your banked C code to put them into the CODE0, CODE1, etc. segments.

Finally, you will have to manually bankswitch before calling any of your banked code... or actually I think calima implemented a way to automate it, but you'll need to write an assembly wrapper for it: https://forums.nesdev.com/viewtopic.php?f=2&t=15959


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

All times are UTC - 7 hours


Who is online

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