CA65: how to get a simple one file binary for a EEPROM/Flash

Programming the 6502 microprocessor and its relatives in assembly and other languages.
User avatar
willie68
Posts: 54
Joined: 27 Jul 2022
Contact:

CA65: how to get a simple one file binary for a EEPROM/Flash

Post by willie68 »

purely out of curiosity,
normally i'm working with retroAssembler for my sbc. But jesterday, purely out of curiosity, i had a look into CC65 and the CA65.
But i didn't get that working. In my asm file i have some jump tables just like this:

Code: Select all

jump_table: 
.segment "JUMPTABLE"

	.org $FF00 ; STROUT output string, A = high, X = low
	jmp do_strout

	.org $FF81 ; SCINIT Initialize "Screen output", (here only the serial monitor)
	jmp do_scinit
	
	.org $FF84 ; IOINIT Initialize VIA & IRQ
	jmp do_ioinit

	.org $FF87 ; RAMTAS RAM test and search memory end
	jmp do_ramtas

	.org $FF8A ; RESTOR restore default kernel vectors
	jmp do_restor 
As you can easily see, the individual jumps are not continuously connected. If I now specify the segment for the table, the 1st jump is placed correctly, but the others specified with .org are not. However, everything is correct in the list file. So I suspect that the linker is not configured correctly here. How do I set this up correctly?
don't count on me, i'm engineer (Animotion)
my arduino pages: http://rcarduino.de
jeffythedragonslayer
Posts: 114
Joined: 03 Oct 2021

Re: CA65: how to get a simple one file binary for a EEPROM/F

Post by jeffythedragonslayer »

willie68 wrote:
the 1st jump is placed correctly, but the others specified with .org are not.
I don't see a jmp that lacks the .org directive?
User avatar
willie68
Posts: 54
Joined: 27 Jul 2022
Contact:

Re: CA65: how to get a simple one file binary for a EEPROM/F

Post by willie68 »

Thats the point, but in the linker generated bin file, all jump are directly behind each other, ignoring the .org directrive.
Screenshot 2022-08-26 09.12.04.png
With retro assembler (which didn't need a linker) it work like charm. But retroassembler is a assembler only.
don't count on me, i'm engineer (Animotion)
my arduino pages: http://rcarduino.de
jeffythedragonslayer
Posts: 114
Joined: 03 Oct 2021

Re: CA65: how to get a simple one file binary for a EEPROM/F

Post by jeffythedragonslayer »

I don't know why you navigated to $1F00 in the screenshot. That's quite the distance from $FF00 where the first JMP opcode should be.
User avatar
willie68
Posts: 54
Joined: 27 Jul 2022
Contact:

Re: CA65: how to get a simple one file binary for a EEPROM/F

Post by willie68 »

because the eeprom base adress is at $e000,
so $1f00 +$e000 = $ff00
don't count on me, i'm engineer (Animotion)
my arduino pages: http://rcarduino.de
jeffythedragonslayer
Posts: 114
Joined: 03 Oct 2021

Re: CA65: how to get a simple one file binary for a EEPROM/F

Post by jeffythedragonslayer »

How does the EEPROM base address being at $e000 make you want to look at $1F00? edit: ok, I see you added an addition.
jeffythedragonslayer
Posts: 114
Joined: 03 Oct 2021

Re: CA65: how to get a simple one file binary for a EEPROM/F

Post by jeffythedragonslayer »

What does the line containing "JUMPTABLE" in your mem map config file look like?
User avatar
willie68
Posts: 54
Joined: 27 Jul 2022
Contact:

Re: CA65: how to get a simple one file binary for a EEPROM/F

Post by willie68 »

THis is the full config file

Code: Select all

MEMORY 
{ 
    ZP: start=$0, size=$100, type=rw, define=yes; 
    RAM: start=$200, size=$7fff, type=rw, define=yes; 
    ROM: start=$e000, size=$2000, type=rw, fill=yes, fillval=$ea, file=%O; 
} 
 
SEGMENTS 
{ 
    ZEROPAGE: load=ZP, type=zp; 
    CODE:     load=ROM, type=ro;
	VECTORS:  load=ROM, start= $fffa, type= overwrite;
	JUMPTABLE:  load=ROM, start= $ff00, type= overwrite;
}
don't count on me, i'm engineer (Animotion)
my arduino pages: http://rcarduino.de
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: CA65: how to get a simple one file binary for a EEPROM/F

Post by GARTHWILSON »

willie68 wrote:
because the eeprom base adress is at $e000,
so $1f00 +$e000 = $ff00
I hardly know anything about linkers. I used one 30+ years ago, but with a batch file set up by someone else (who initially had a lot of trouble getting it going), and I modified it from the templates for different projects without really understanding it. However, I still wonder if you're trying to use the linker for something that's not generally the linker's job. (E)EPROM programmers' driver software offer offsets, sets, splits, and so on, and the file pointer, buffer pointer, and device pointer can all be different. I now use the Cross-32 (C32) assembler which does not use a linker.
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?
jeffythedragonslayer
Posts: 114
Joined: 03 Oct 2021

Re: CA65: how to get a simple one file binary for a EEPROM/F

Post by jeffythedragonslayer »

Not sure; since you know the first jmp is in the correct spot, can you try putting each jmp in its own segment and specify the addresses you were using with .org in the memmap configuration? JUMPTABLE1, JUMPTABLE2, etc.
User avatar
willie68
Posts: 54
Joined: 27 Jul 2022
Contact:

Re: CA65: how to get a simple one file binary for a EEPROM/F

Post by willie68 »

But than i double the effort, have to insert .segment and .org part in asm, and a segment in the configuration...
I'm looking for an easy solution for this...
don't count on me, i'm engineer (Animotion)
my arduino pages: http://rcarduino.de
User avatar
Proxy
Posts: 746
Joined: 03 Aug 2018
Location: Germany

Re: CA65: how to get a simple one file binary for a EEPROM/F

Post by Proxy »

If you use .segement you don't need .org
I have something similar for the ROM of my 65816 SBC. Once I get home I can see If I can get your example to work
User avatar
willie68
Posts: 54
Joined: 27 Jul 2022
Contact:

Re: CA65: how to get a simple one file binary for a EEPROM/F

Post by willie68 »

Proxy wrote:
If you use .segement you don't need .org
I have something similar for the ROM of my 65816 SBC. Once I get home I can see If I can get your example to work
But the effort for this, creating a segment for every bios routine jump, is quite high for such a simple requirement.
I open an issue to the developer of CA65 (https://github.com/cc65/cc65/issues/1841) maybe they have another simple idea.
Otherwise maybe CA65 is the wrong tool for this and for me... i like KISS
don't count on me, i'm engineer (Animotion)
my arduino pages: http://rcarduino.de
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: CA65: how to get a simple one file binary for a EEPROM/F

Post by BigEd »

Could you add in a DB or similar 'declare bytes' padding to fill in between the JMPs? I suppose that's a little manual.
User avatar
Proxy
Posts: 746
Joined: 03 Aug 2018
Location: Germany

Re: CA65: how to get a simple one file binary for a EEPROM/F

Post by Proxy »

i commented on the github issue suggesting basically what BigEd said, ca65 has the ".res" (aka reserve) directive which allows you to insert x amount of bytes directly where you placed it in the assembly file.
using it the jumps can be pushed apart without messing with segments, but obviously it takes a bit of work as you need to do the math to know how large the gaps should be.
Post Reply