CPCWiki forum

General Category => Programming => Topic started by: norecess on 12:37, 24 March 10

Title: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: norecess on 12:37, 24 March 10
Hi there !

It makes few weeks I have been working on a C compiler targeting Amstrad CPC platforms. Now that that version 1.0 is finished, I'm releasing it today!

The name of the compiler is PhrozenC, and is available under several versions :
- a PC version   (command-line)
... the best is coming :
- a CPC version (ROM format, use that version if you can!)
- a CPC version   (64Kb-compatible, stand-alone application which reset after execution)
-   a CPC version (128Kb, usable via RSX).

What is main fact to note?
On a PC, it compiles a .C file and it will generate a .ASM file ready to be compiled with WinAPE On a CPC, it compiles a .C file and it will generate a .ASM file ready to be compiled with... Maxam !
In both cases, the same exact .ASM file will be generated. As a consequence, everyone is free to choose to directly program in C on CPC, or enjoy the speed of a PC instead...

PhrozenC is released with a manual (PDF-format, 33 pages), covering all the things you have to know   about to start programming using PhrozenC. There is even a small tutorial about learning C for the newcomers.
Example sources are available, as also a small set of library files handling file management, graphics, memory management, string concatenation, etc..

This   is version 1.0 . I plan to get your feedbacks and provide better versions with time...

Please, before any technical questions   about PhrozenC, make sure you fully read the documentation.

Thanks to all the guys that helped me on this port, it was not that easy to get it working on a real CPC... (http://cmussaperetto3.free.fr/IMPACT/FORUM/images/smilies/smiley.gif)

DOWNLOAD LINK : http://sourceforge.net/projects/phobia/files/PhrozenC-10.zip/download
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: Gryzor on 12:55, 24 March 10
Ooh! Nice! Posted on the wiki's front page. Screenshots? :D
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: norecess on 13:43, 24 March 10
It's kind of weird to ask a screenshot for a C compiler, but eventually, I did this for you :)

https://sourceforge.net/apps/trac/phobia/attachment/wiki/PhrozenC/cc_screenshot.png
https://sourceforge.net/apps/trac/phobia/attachment/wiki/PhrozenC/cc_screenshot2.png
https://sourceforge.net/apps/trac/phobia/attachment/wiki/PhrozenC/cc_screenshot3.png
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: mr_lou on 14:02, 24 March 10
Nice!!  :)
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: Gryzor on 14:07, 24 March 10
Well, what can I say, I'm an optical guy :)
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: Devilmarkus on 14:09, 24 March 10
Quote from: Gryzor on 14:07, 24 March 10
Well, what can I say, I'm an optical guy :)

We remember: (http://cpcwiki.eu/forum/6a00e0098c505188330115709e7fba970b-450wi.jpg)
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: Gryzor on 14:11, 24 March 10
Ah shurrup, you!
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: Bryce on 14:20, 24 March 10
Amazing. Just downloaded it. I'll try out the ROM version tonight and return with some feedback....

Bryce.
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: norecess on 14:51, 24 March 10
Quote from: Bryce on 14:20, 24 March 10
Amazing. Just downloaded it. I'll try out the ROM version tonight and return with some feedback....

Bryce.

I need feedback! :)
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: redbox on 17:10, 24 March 10
Sounds great, especially as you can easily "see" the assembler it creates due to it outputting .asm files.

Can't wait to try it out...  :)
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: nurgle on 16:01, 25 March 10
Cool!
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: mr_lou on 06:54, 26 March 10
All it needs now is a way to compile the ASM into binary on Linux.
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: arnoldemu on 10:36, 26 March 10
Quote from: mr_lou on 06:54, 26 March 10
All it needs now is a way to compile the ASM into binary on Linux.
pasmo?
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: mr_lou on 10:40, 26 March 10
Oh, pasmo can compile the ASM generated by PhrozenC? Groovy then.  :)
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: norecess on 19:18, 26 March 10
Yes, it should compile OK with Pasmo. That said, I can only guarantee WinAPE and Maxam compatibility for now - I don't want to lose focus on what really matters by supporting multiple platforms/compilers/whatever.
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: norecess on 04:25, 27 March 10
I just released version 1.1 of PhrozenC, get it here : https://sourceforge.net/projects/phobia/

Changelog :

Version 1.1
- CC (Win32) Fixed crash when included file does not exist
- Fixed crash when calling CC with a C file entirely created on a CPC
- Fixed CS RSX-command usage. Now only ROM-based, but 100% safe.
- Updated documentation with compiler internal section

Version 1.0
- Initial release..

Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: TFM on 21:31, 05 April 10
Hy,
Great project!!! Did somebody already try the FIOLIB with PhrozenC???
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: norecess on 01:34, 06 April 10
Hi TFM ..

You made me smile  ;D because of this :

http://cpcwiki.eu/forum/index.php?topic=443.0

No answer yet ? Try it yourself ! :)
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: TFM on 03:42, 08 April 10
Quote from: norecess on 01:34, 06 April 10
Hi TFM ..

You made me smile  ;D because of this :

http://cpcwiki.eu/forum/index.php?topic=443.0 (http://cpcwiki.eu/forum/index.php?topic=443.0)

No answer yet ? Try it yourself ! :)

Oeahm, ok, after finishing the OP translation ;-) Seriously, I miss a lot of my CPC stuff here in USA. Will care about it ASAP. And sometimes a question is faster than DIY ;-)
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: norecess on 14:44, 08 April 10
Are you living in USA or just a trip ?

I'm living in Canada and I had to get a full working CPC there ! :)
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: TFM on 04:00, 20 April 10
Quote from: norecess on 14:44, 08 April 10
Are you living in USA or just a trip ?

I'm living in Canada and I had to get a full working CPC there ! :)

Well, I'm in New Orleans since 18 months, 19 days and nearly 22 hours... to run a CPC with 110 Volt, 60 Hz is a problem for me...

Canada is a civilized country, metric system, educated people and maybe... 220 Volt???

However... in 3 weeks and 3 days I have two weeks holydays in Munich! All my CPCs are there ;-)
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: norecess on 16:34, 22 April 10
No, I had to buy a power-converter (110 to 220), and the monitor is a real Amstrad one.
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: TFM on 17:29, 22 April 10
Quote from: norecess on 16:34, 22 April 10
No, I had to buy a power-converter (110 to 220), and the monitor is a real Amstrad one.

Must have been a pain in the aXX to get that monitor there. I remember when Tolkin tried to get a monitor from France to Munich, the plain started 20 minutes to late ;-)
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: AMSDOS on 09:26, 29 July 10
It's a pity I found C Language pretty hard going given I do Pascal alright (and managed a simple Bouncing Ball Demo in Small-C with a lot of ASM86), just wondered how PhrozenC goes when handling those Library files. Biggest setback in Turbo Pascal for instance is at Compilation Time when a 6 or 7k Library is jammed into the COM file, the whole thing isn't necessarily used which is most annoying! Unfortunately I've only have a readable source of the 16bit Version - maybe able to get clues from it using Standard code.
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: TFM on 05:21, 30 July 10
Hi, here my wired question again... anybody tried the FIOLIB with PhrozenC? I can't program C, only Z80, so I really don't know how to test it.
But hey, you will get any kind of LIB function you want, just tell me. And FIOLIB is already able to break the 64 KB barrier. So if somebody gives it a try, I would appreciate if you share your experience here.
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: norecess on 15:32, 18 August 10
I don't know what FIOLIB is. But I don't see why it could not?
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: TFM on 01:37, 19 August 10
Quote from: norecess on 15:32, 18 August 10
I don't know what FIOLIB is. But I don't see why it could not?

The FIOLIB is the IO-LIB for FutureOS, take a quick look here:
http://www.cpcwiki.eu/index.php/FIOLIB (http://www.cpcwiki.eu/index.php/FIOLIB)

Beside the usual functions it has additional fuctions like: circle, cls, plot, draw, mode, pen, ink...

It works with Small-C, but it would be interresting to see it working with PhrozenC. Guess it could boost it, if they work together.
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: AMSDOS on 11:27, 09 September 13
I was reading that this compiler is based on Small-C, so it should work, though when I was working with Small-C I had to use COMFU to convert the COM file into a FutureOS file. I'm guessing that if the output files PhrozenC makes are different (e.g. BIN) they would need to be converted into .COM files in order to make them FutureOS if the SMC files have a different structure. Otherwise if Assembly is produced and can be compiled into a COM file that way, it would be easier to produce the SMC file.

Unfortunately I cannot seem to get a copy of PhrozenC just to see - all the links to it appear to be dead, including the one on CPCWiki.
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: Munchausen on 13:44, 09 September 13
You can still get PhrozenC, and the manual, at CPCRULEZ &#9733 CODING &#9733 CROSSDEV &#9733 PHROZEN C by NORECESS{UK} (http://cpcrulez.fr/coding-crossdev-phrozenC.htm)


I'd like to have a bash at this soon too. However, for bigger productions it looks like SDCC is definitely the way to go, see the awesome tutorials over at http://www.cpcmania.com/Docs/Programming/Programming.htm
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: TFM on 19:27, 09 September 13
Quote from: AMSDOS on 11:27, 09 September 13
I was reading that this compiler is based on Small-C, so it should work, though when I was working with Small-C I had to use COMFU to convert the COM file into a FutureOS file. I'm guessing that if the output files PhrozenC makes are different (e.g. BIN) they would need to be converted into .COM files in order to make them FutureOS if the SMC files have a different structure. Otherwise if Assembly is produced and can be compiled into a COM file that way, it would be easier to produce the SMC file.


Well, COMFU (like COMAM) does just one thing: It adds an 128 Byte Header to the file. Since Amsdos / FutureOS do like at .COM files like at ASCII files, then need to get a header.


If PhrozenC produces already a binary output file, then it should be possible to start it directly without the need of using COMFU or COMAM. So things would be more easy, but I never gave it a try for lack of time reasons.[nb]And sadly this nice PhrozenC seems not to be updated any longer.[/nb]

Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: AMSDOS on 09:44, 10 September 13
Quote from: TFM on 19:27, 09 September 13

Well, COMFU (like COMAM) does just one thing: It adds an 128 Byte Header to the file. Since Amsdos / FutureOS do like at .COM files like at ASCII files, then need to get a header.


If PhrozenC produces already a binary output file, then it should be possible to start it directly without the need of using COMFU or COMAM. So things would be more easy, but I never gave it a try for lack of time reasons.[nb]And sadly this nice PhrozenC seems not to be updated any longer.[/nb]

Ok, I wasn't sure if the Headers were structured differently in those Operating Systems, which was why I was querying about it. Earlier on when I was using Small-C to make Future-OS programs, I was using COMAM to put a header to the file, though when I was going to load it, it wasn't displaying the Small-C Program icon and displaying some funny Header blocks, even though I renamed it with the SMC extension.
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: AMSDOS on 10:13, 10 September 13
Quote from: Munchausen on 13:44, 09 September 13
You can still get PhrozenC, and the manual, at CPCRULEZ &#9733 CODING &#9733 CROSSDEV &#9733 PHROZEN C by NORECESS{UK} (http://cpcrulez.fr/coding-crossdev-phrozenC.htm)


I'd like to have a bash at this soon too. However, for bigger productions it looks like SDCC is definitely the way to go, see the awesome tutorials over at http://www.cpcmania.com/Docs/Programming/Programming.htm

Well I noticed that Phrozen C supports FOR Loops, so I guess it supports WHILE loops as well (as Small-C Does), and from the manual it looks as if it's easier to incorporate C Declared Variables into Inline Assembly, which found really awkward to do from Small-C.
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: Munchausen on 10:47, 10 September 13
Quote from: AMSDOS on 10:13, 10 September 13
Well I noticed that Phrozen C supports FOR Loops, so I guess it supports WHILE loops as well (as Small-C Does), and from the manual it looks as if it's easier to incorporate C Declared Variables into Inline Assembly, which found really awkward to do from Small-C.


Did you read SDCC as small C? I think SDCC is better because it supports the full C spec (modern, not K&R), unlike Phrozen-C and Small-C, and has a full optimiser so makes much better code.


Of course, it doesn't run on the CPC so you must build your code on the PC and copy it over (though, it suddenly occurs to me that if you had enough RAM you could build SDCC for the CPC using SDCC and run it locally... madness!)
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: AMSDOS on 11:35, 10 September 13
Quote from: Munchausen on 10:47, 10 September 13

Did you read SDCC as small C? I think SDCC is better because it supports the full C spec (modern, not K&R), unlike Phrozen-C and Small-C, and has a full optimiser so makes much better code.

No, I'm the guy that made 2 demo programs (http://www.cpcwiki.eu/forum/index.php?topic=1381.msg66182#msg66182) for FutureOS using Small-C & FIOLIB.  ;D

Granted SDCC is better, though I play around with more inferior languages.  8)

QuoteOf course, it doesn't run on the CPC so you must build your code on the PC and copy it over (though, it suddenly occurs to me that if you had enough RAM you could build SDCC for the CPC using SDCC and run it locally... madness!)

Not to mention that if it's a PC based language, the code is optimised to strictly target specific code which is used for the program instead of just plonking in a 5-6k Library file with everything in it?
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: Munchausen on 12:00, 10 September 13
Sorry, you changed the topic from sdcc to small-c and confused me (I didn't say anything about for loops or inline assembly)  ???




Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: AMSDOS on 12:11, 10 September 13
Quote from: Munchausen on 12:00, 10 September 13
Sorry, you changed the topic from sdcc to small-c and confused me (I didn't say anything about for loops or inline assembly)  ???

Sorry I was referring to Phrozen C and some of the features it had which Small-C doesn't support and unfortunately I forgot to edit your comments about SDCC out. Though I'm sure that SDCC can do all that and more I guess. At this point of time though I'm only doing small scale C stuff.
Title: Re: Programming in C using only a real CPC : PhrozenC is out ! :)
Post by: AMSDOS on 07:31, 02 November 19
Quote from: TFM on 05:21, 30 July 10
Hi, here my wired question again... anybody tried the FIOLIB with PhrozenC? I can't program C, only Z80, so I really don't know how to test it.


I got around to trying PhrozenC today and noticed some superficial differences from Small-C, in my test programme I had from Small-C I had to change the #include statement so the filename was in inverted commas ("") and when I got around to Assembling the resulting Source Code, assembly from the small-c include file had to be altered so hexadecimal begins with the ampersand (&), because PhrozenC uses Maxam or Winape Assembler.
I also noticed that PhrozenC has ditched the ".h" files which Small-C had and simply includes other c header files with addresses defined within. The additional library files PhrozenC uses has changed some of the routines names as well.


During todays experience I was trying to use a Library file I had from Small-C with PhrozenC, but in frustration I chucked it out and focused on the PhrozenC Libraries instead. Most of the stuff I needed was present, one of the routines I had to modify from the original Small-C 'putchar();' and I was able to include other routines to generate Random Numbers and simple Screen Scrolling using SCR HW ROLL.
The only other trouble I had was trying to Redefine Characters working and I wanted to setup a Place using an Array to hold the Matrix Data (PhrozenC's way of saying SYMBOL AFTER xxx) to cater for more Redefined Graphics. Eventually I managed to get one working with the Array by looking at how other Firmware Library routines handled it when HL & DE registers were POPed and PUSHed before CALLing their relevant routines, and all I had to do was specify from which Character Number I wanted to use and point to the Name of the Array (without specifying a specific spot).
The Generated Assembly file was 12kb in size, with a number of extra routines chucked in for the Ride, though even when I finally got the code working, I was still poking about with the Source Code, changing ints to char which didn't seen to bother PhrozenC in the context of having Integer based combining with Char byte types. Once I was happy with the final code, the resulting StarScrl Demo was just over 700 bytes in length.
Powered by SMFPacks Menu Editor Mod