News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

Fortran prgramming on CPC?

Started by sigh, 23:52, 19 January 17

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sigh

I read that Fortran is a very good programming language for creating extremely fast and small code due to it's heavy bias towards mathematics, where it is used by mostly non-computer engineers and scientists.

Has anyone tried using this language on the Z80 processor?

AMSDOS

I'm not sure which Fortran you're referring to, the Fortran book I have deals in code for Fortran-77 for Engineers & Scientists. I haven't used Fortran on a Z80, Digital Research made one, which I played around with once under CP/M-86, the CMD file it produced was somewhere over 100Kb and 640Kb, which I guess could be considered small from a PC perspective  :laugh:


Fortran-77 is perhaps the most popular of Fortran Languages, though they go back to 1957 and there's also Fortran-90, I'm unsure if there's anything later than that, this Tree doesn't think so.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

sigh

Thanks for the reply.

I wasn't sure if any form of Fortran language existed on the Z80, so it's interesting to hear that it does exist.

How feasible would it be to code a game using this language on the CPC?

GeoffB17

Hello,


Well, they say that a good programmer can do just about whatever with any language, butthere are limits to that.   Many things are just so much easier to do with certain languages, or rather with the available implementations of them.


As you suggest, fortran (as in FORmulae TRANslation) was a pretty early language primarily aimed at mathematical things, and it has heavy leanings towards such things.   I doubt it has much facility for graphics etc, i.e. many of the things you might want for a 'game'.   But then, what constitutes a 'game'?  Prob early chess implementaions (no graphics) could have been done in fortran?  You could make a game involving lots of numerical manipulation?


There was a 'joke' document I have somewhere, called 'Real programmers don't use Pascal' which, among other things, details many things 'real' programmers have achieved using fortran (i.e. early programmers at JPL not only finding an unknown moon of saturn (I think it was Saturn) but getting the spacecraft to photograph it as well.


If you're interested, I do have a CP/M copy of fortran (and in fact one of cobol as well) but I've no idea what version this is.   I could find that out for you, and post it if it's any use?


I never tried to do anything with it, so much easier to do the things I wanted with other languages!


Geoff.

GeoffB17

Additional info..


I've found my disk.


The fortran I have is Microsoft Fortran v3.43 dated 26/06/81


This is a compiler, which can be used to build .LIB (library) files, as well as the finished .COM.  The files I have include a library, and the LINK/L80 lib prog, plus a couple of small example progs, parts of which are in German.


I'd guess that the facilities of this fortran are pretty limited to it's intended purposes, i.e. maths/statistics etc?


Geoff.

AMSDOS

Quote from: sigh on 13:08, 21 January 17
Thanks for the reply.

I wasn't sure if any form of Fortran language existed on the Z80, so it's interesting to hear that it does exist.

How feasible would it be to code a game using this language on the CPC?

Fortran 77 (or I should say FORTRAN, short for FORmula TRANslation), appears to have the kind of features (e.g. Loops, Array's, Variables) for building a simple game, like @GeoffB17 has mentioned, "what constitutes a 'game'?". A lot of the BASIC games from the Usborne books like "Computer Battlegames" or "Computer Spacegames" rely heavily on Random Numbers, unfortunately that isn't documented in my FORTRAN-77 book, though that's not to say it doesn't exist as the title suggests it's "For Engineers and Scientists", they may have little use for Random Numbers. The good news is it maybe possible to write one as a FUNCTION subprogram, or perhaps any good FORTRAN Usenet group might have one, worth checking on Google Groups, though you would still be looking at a simple Text based game. All the FORTRAN programs I've noticed operate through CP/M, so in one way a CP/M User would be happy to see it as a Text based game, have no idea how you'd get GSX to operate from a FORTRAN program if you wanted to make a compatible Graphics game between CP/M systems, nor does my book discuss how to get an assembly routine. As I recall "Real Programmers don't use Pascal" talks about FORTRAN & Assembly, but I think it separates the two by saying if it can't be done in FORTRAN do it in Assembly, if it can't be done in Assembly, it isn't worth doing.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

SRS

well, take a look 'ere: https://people.sc.fsu.edu/~jburkardt/f_src/f_src.html

I did port a student course related software from FORTRAN77 to C in the early 90's at university - but on 386 those days.
That was due to the old computer running it was getting ... welll ... end of life.

I'd really recommend C for games on Z80 - using cpctelera or the libs proviced with z88dk - even better ASM.

GeoffB17

Well, I don't know how far you can, or would want to take this.


I don't know so much about the CPCs, I suppose it depends on which CPC you have, but if you have floppy disk, and can run CPM, then one door opens.


If you look up the version of Fortran 80 on the web, you can download the setup, or I can supply you a copy of what I've got.   Also, the full MS manual can be downloaded as a PDF.


On the basis of a quick look, the MS system would seem to be fully consistent with other MS languages of that era, i.e. MASM.


So you can create modules (and .REL files) from fortran, ASM and whatever, put them together into one of more libs using L80, then use LINK to add things together.   If you can access CPC graphics routines from CP/M, then maybe you can go places.


I suspect the REAL CPC games need to take over the complete machine for FULL access to ALL the facilities, and hence may not allow CP/M, but maybe you can still access some graphics/sound bits.   If you're using a range of MS languages, then you'll have less trouble keeping things compatible, so that could help.


Detailed reading of the F80 manual should give further info.


Best of luck.


Geoff

AMSDOS

#8
Quote from: SRS on 23:21, 21 January 17
I'd really recommend C for games on Z80 - using cpctelera or the libs proviced with z88dk - even better ASM.


That's if they don't mind sorting out any Installation Problems they may/may not encounter.  ;D
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

robcfg

It's not CPCTelera's fault, blame that on Microsoft for not making Windows POSIX  compliant.

Works like a charm under Linux and OSX.


Sent from my iPhone using Tapatalk

sigh

@GeoffB17: Thanks for the offer - however I'm not a programmer :) . I was just wondering about different programming languages available on the CPC that I don't really hear about like Fortran, Cobol, Modular 2 and others.

andycadley


Quote from: robcfg on 12:13, 22 January 17
It's not CPCTelera's fault, blame that on Microsoft for not making Windows POSIX  compliant.

Works like a charm under Linux and OSX.
Windows is POSIX compliant, Cygwin is not. You'd probably be better off ditching it and using the built in Bash shell.

robcfg

You mean that Windows 10 Linux subsystem is POSIX compliant.


If that's the case, sure.


But it's the same as having Linux running under VirtualBox or VMWare. It doesn't make Windows POSIX per se, it's a workaround.


Anyway, if it works for you, cool then!


I just don't like Windows 10.

andycadley


All NT variants have had a POSIX subsystem of some variety (first the POSIX subsytem, then the Interix SFU version and finally the Subsystem for Linux) which expose the kernel level functions as a true POSIX OS (the way NT works is that APIs are exposed via subsytems, of which Win32 is only one). The Linux one obviously offers the best compatibility both because it's based on a newer POSIX standard and because it also handles the quirks of Linux (which is the pretty much the most used POSIX system anywhere).


Cygwin is the hacky workaround, because it attempts to fake some degree of POSIX over the top of Win32, even though all the underlying semantics of Win32 process and files is completely incompatible. It's never been very good at it (even fork is officially documented as sometimes failing for "no reason" with the advice you just try again). Honestly you've always been much, much better off using a Linux VM over it at every point.

andycadley

Anyway, back to FORTRAN. It's not a language I ever saw much of on 8-bit machines, possibly because it's overly verbose syntax makes it a difficult thing to squish into limited RAM. From what I remember of it, I wouldn't really want to try and write a game in it in any case. If I were going for an alternate tool, a FORTH compiler might be more suited and I vaguely remember an AA review of at least one, no idea how good it was though.

netmercer

Hi,
Microsofts F80 Compiler was a Fortran IV Compiler, a subset of Fortran77.
Because of its possibility for BDOS calls it is no problem to implement GSX under CP/M+. (I did this in the 80's and it works fine, but was quite slow)
For game programming it's probably not the first choice.

Kind regards
netmercer

AMSDOS

Quote from: robcfg on 12:13, 22 January 17
It's not CPCTelera's fault, blame that on Microsoft for not making Windows POSIX  compliant.



Understand it's the tools it's using which is causing all the grief.


Haven't seen any Games on a CPC written in Forth, but it's more than capable after playing some on a Jupiter Ace which has less memory, okay it comes with Forth in ROM, though Jupiter Ace only has something like 16Kb as standard.


Arnor also brought BCPL to the CPC (Disk/ROM), which has a nice Space Invaders game along with a range of other example programs, the programs compiled are also quite small (around 4Kb minimum), languages like Hisoft Pascal 4t takes up 7Kb minimum.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Powered by SMFPacks Menu Editor Mod