Forum > FPC development

Possible to create a 6502/65c02 target for FreePascal

(1/3) > >>

kveroneau:
I am working on various 65c02 projects, and would like to know how easy it would be to create a new target for FreePascal to compile programs to generate 6502 binary code with custom load addresses?  I have been recently using the rather useful cc65.org project, which is basically a set of binutils and a C compiler to target the 6502 family of processors.  I am looking through the FreePascal source tree to better understand how the RTL works, and I do see assemble language code in various units.  Is creating a new target as simple as updating these assembly instructions to 65c02 assembly, and having it use the ca65 assembler and ld65 linker to build the RTL units?

I found and read the following wiki pages, but they aren't as helpful as I would otherwise prefer them to be:
http://wiki.freepascal.org/Porting_Free_Pascal
http://wiki.freepascal.org/System_unit_structure
http://wiki.freepascal.org/Porting_Free_Pascal_Example

To be clear, I'm not interested in porting the compiler, but just allowing FPC to build 6502 compatible binary files.  I was able to easily update cc65 to build binaries for custom targets using custom memory maps and load addresses.  I was hoping it might be just as easy to update FPC to perform a similar feat.

cc65 (6502 binutils): http://www.cc65.org/

Is there a document perhaps that explains the actual compile/build process of a Pascal program to machine code and what exactly is involved?  Could FPC say output 6502 assembly code, which can then be used with ca65 to generate my desired binary image?

Any assistance on this matter would be most grateful.

marcov:
No, it is not as simple as simply upgrading the RTL to use 6502/10 assembler.

The main thing is actually writing a 6502 codegenerator, which is quite involved.

tr_escape:
Maybe you and "t-edson" can work together :

http://forum.lazarus.freepascal.org/index.php/topic,36595.0.html

But how many cpu 6502 are there in the market? I just wondered.

kveroneau:

--- Quote from: tr_escape on January 03, 2018, 08:41:18 pm ---Maybe you and "t-edson" can work together :

http://forum.lazarus.freepascal.org/index.php/topic,36595.0.html

--- End quote ---
Thank you, I will look into this as a potential option.


--- Quote from: tr_escape on January 03, 2018, 08:41:18 pm ---But how many cpu 6502 are there in the market? I just wondered.

--- End quote ---
The 6502 is sometimes used as an alternative chip in embedded systems, an alternative to an AVR, ATmega, ARM, and embeeded Intel chips.

Considering there is a working C compiler, and a dedicated active forum for the 6502: http://6502.org/  I believe it has a fairly sized userbase.  WDC still produces the chips and sells them:  http://www.westerndesigncenter.com/wdc/

Pascal was one of the languages also supported on the original Apple 2, which also ran the 6502.  It would be really nice if FPC could for example, compile these old Pascal programs and either target modern machines, or even the original Apple 2 hardware.  FPC does preserve the dialect from the TurboPascal days, and old DOS TP7 programs can be ported to modern systems as a result.

Blaazen:
Are you planning to develop for revival of never released Commodore 65, http://mega65.org/?  :)

Navigation

[0] Message Index

[#] Next page

Go to full version