Beginners cc65

Programming the 6502 microprocessor and its relatives in assembly and other languages.
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Beginners cc65

Post by BigEd »

Any bad aspect of the first scenario?
User avatar
Dajgoro
Posts: 808
Joined: 08 Aug 2011
Location: Croatia
Contact:

Re: Beginners cc65

Post by Dajgoro »

The first scenario when everything is in ram, it all works perfectly...
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Beginners cc65

Post by BigEd »

Sounds good to me! If it's also what you see for other platforms, there may be a reason.
User avatar
Dajgoro
Posts: 808
Joined: 08 Aug 2011
Location: Croatia
Contact:

Re: Beginners cc65

Post by Dajgoro »

I tried to move the ram to the rom range, and it works...
But still everything is in ram.
User avatar
Dajgoro
Posts: 808
Joined: 08 Aug 2011
Location: Croatia
Contact:

Re: Beginners cc65

Post by Dajgoro »

I found the source of the problem. It is the DATA segment.

In this scenario it works.

Code: Select all

MEMORY {
	HEADER:  start = $C000, size = $0004, type = ro;
	ZP:      start = $0000, size = $00D0, type = rw, define = yes;
	RAM:     start = $0200, size = $1E00, file = %O, define = yes;
	ROM:     start = $C200, size = $3CFF, file = %O, define = yes;
}
SEGMENTS {
	EXEHDR:   load = HEADER,          type = ro;
	STARTUP:  load = ROM, type = ro;
	LOWCODE:  load = ROM, type = ro,               optional = yes;
	INIT:     load = ROM, type = ro, define = yes, optional = yes;
	CODE:     load = ROM, type = ro;
	RODATA:   load = ROM, type = ro;
	DATA:     load = ROM, type = rw;
	BSS:      load = RAM, type = bss, define = yes;
	HEAP:     load = RAM, type = bss, optional = yes; # must sit just below stack
	ZEROPAGE: load = ZP,  type = zp;
}
But when i send the DATA segment in ram, it sets the jmp instructions to 0000

Code: Select all

MEMORY {
	HEADER:  start = $C000, size = $0004, type = ro;
	ZP:      start = $0000, size = $00D0, type = rw, define = yes;
	RAM:     start = $0200, size = $1E00, file = %O, define = yes;
	ROM:     start = $C200, size = $3CFF, file = %O, define = yes;
}
SEGMENTS {
	EXEHDR:   load = HEADER,          type = ro;
	STARTUP:  load = ROM, type = ro;
	LOWCODE:  load = ROM, type = ro,               optional = yes;
	INIT:     load = ROM, type = ro, define = yes, optional = yes;
	CODE:     load = ROM, type = ro;
	RODATA:   load = ROM, type = ro;
	DATA:     load = RAM, type = rw;
	BSS:      load = RAM, type = bss, define = yes;
	HEAP:     load = RAM, type = bss, optional = yes; # must sit just below stack
	ZEROPAGE: load = ZP,  type = zp;
}
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: Beginners cc65

Post by GARTHWILSON »

I just found, by accident, that Wikipedia has an article on cc65, and http://en.wikipedia.org/wiki/Cc65 .

Edit, 2/14/21: I just came across this page about benchmarking the various C compilers for the 6502. CC65 produced much slower, more bloated code than the other C options, although it was more solid.
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?
User avatar
Dajgoro
Posts: 808
Joined: 08 Aug 2011
Location: Croatia
Contact:

Re: Beginners cc65

Post by Dajgoro »

I've finally found the documentation what i was looking for. Here it is, and it explains how to boot the code from rom.
http://www.cc65.org/doc/customizing-2.html
White Flame
Posts: 704
Joined: 24 Jul 2012

Re: Beginners cc65

Post by White Flame »

Dajgoro wrote:
Where are the document that describe the configuration files, i can't find them...
The reference for the config files is actually under the ld65 section: http://www.cc65.org/doc/ld65-5.html
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Beginners cc65

Post by BigEd »

You might find some help at http://www.fririki.net/6502/cc65_sbc.html
User avatar
Dajgoro
Posts: 808
Joined: 08 Aug 2011
Location: Croatia
Contact:

Re: Beginners cc65

Post by Dajgoro »

Thanks for the link.
User avatar
Dajgoro
Posts: 808
Joined: 08 Aug 2011
Location: Croatia
Contact:

Re: Beginners cc65

Post by Dajgoro »

I tried setting up the cc65 with the sim.cfg from the link, and when i tried to load it in the simulator it won't work. So i checked the disassembled code and the first thing on the address C000 is a loop that writes something to zero page. I tried setting up the start vector, but the simulator doesn't check it, and it just starts executing at the point where i loaded the binary code.
User avatar
8BIT
Posts: 1787
Joined: 30 Aug 2002
Location: Sacramento, CA
Contact:

Re: Beginners cc65

Post by 8BIT »

Hey Dajgoro,

Did you ever get the ROM code to work the way you wanted?

I spent some time with cc65 tonight and think I have a better handle on it now. Will experiment more tomorrow to confirm but I am getting code to load to ROM with the crt0.s code at the starting address. I still need to be sure the DATA segment is being copied to RAM correctly. I should have a working demo ready soon.

Daryl
Please visit my website -> https://sbc.rictor.org/
User avatar
Dajgoro
Posts: 808
Joined: 08 Aug 2011
Location: Croatia
Contact:

Re: Beginners cc65

Post by Dajgoro »

I tried to get it working when i discovered that links, and how to make it boot from rom. But whatever i tried it never worked, and when i would step it in the simulator it seems as if it would never set the reset vector right, so i never managed to boot anything.
If you manage to get it working in the Kowalski simulator like that last example, i would be really grateful.
Also i was thinking since my new cpu board will have the mmu, i could kinda switch programs on the fly, and add sorta of os that would allow to boot other programs into ram. Also i could implement Petit FAT so i can read/write from memory cards as well.
User avatar
8BIT
Posts: 1787
Joined: 30 Aug 2002
Location: Sacramento, CA
Contact:

Re: Beginners cc65

Post by 8BIT »

I did get the "hello1" demo file to load into ROM and run successfully. I think I have the vectors (IRQ,RST,NMI) working too. I end up with a 32768 byte image when I tell it to start at $8000. A smaller ROM would be easy to adjust for.

I need to test it a little more and then will try to document the steps so others can repeat them. Hope to have something ready by the weekend.

My goal is to connect an ENC28J60 Ethernet module to the AVR Emulator and try to serve up a simple web page. I want to include the 8 channel ADC data in web page along with some digital I/O points. That would make a cool remote monitoring system.

Daryl
Please visit my website -> https://sbc.rictor.org/
User avatar
Dajgoro
Posts: 808
Joined: 08 Aug 2011
Location: Croatia
Contact:

Re: Beginners cc65

Post by Dajgoro »

Great!

As for spi ethernet module, any good tutorials on how set up and communicate with it(or how to deal with multiple sessions if they exist).
Post Reply