News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

forth for cpc6128

Started by funkheld, 08:52, 10 October 10

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

AMSDOS

OK - I've downloaded Electro Forth, can somebody recommend some sort of Tutorial guide? Aany specific info I can about Electro Forth I will be interested in too.
* 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

Octoate

#26
If you want to do a benchmark, you shouldn't hardware dependent things like plotting to the screen. As already said, use a math problem. Then you can also compare benchmarks of one equally implemented algorithm in e.g. BASIC, Forth, C, etc.
What about calculating the first 100 prime numbers? Btw, if you guys are interested in a benchmark topic, we should start one and maybe use different ideas to compare speed and code size of the compilers. What do you think?
--

TFM

#27
Quote from: CP/M User on 07:14, 15 October 10
OK - I've downloaded Electro Forth, can somebody recommend some sort of Tutorial guide? Aany specific info I can about Electro Forth I will be interested in too.

You have to start the file "FORTH." from drive B, but you need a disc in A too (for file operations).

Take a look at the commands by typing VLIST (in upper cases).


Quote from: Octoate on 14:01, 15 October 10
If you want to do a benchmark, you shouldn't hardware dependent things like plotting to the screen. As already said, use a math problem. Then you can also compare benchmarks of one equally implemented algorithm in e.g. BASIC, Forth, C, etc.
What about calculating the first 100 prime numbers? Btw, if you guys are interested in a benchmark topic, we should start one and maybe use different ideas to compare speed and code size of the compilers. What do you think?

Calculating the first 100 prime numbers is .... depending on the single routine for calculating that numbers... so it's cpu and / or algorithm dependent.

As you said, different benchmarks would be fine to have - and to compare. Good idea.

The Executioneer also mentioned something about math benchmarks.

Ok, guys, you both are cordially invited to post benchmark code here :-)

TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

AMSDOS

#28
I know nothing about benchmarks :(

Spoiler: ShowHide
 
Though have done some mathematical comparisions between Interpreted BASIC & Compilable Pascal which demonstrated how slow Compilable Pascal was. I just wanted to let you know that BASIC cheats in some instances by using Lookup tables!  >:(  So perhaps avoid using stuff like COS() SIN(), not sure how well it handles other maths.


I downloaded the FIG-FORTH manual, so if some of the rules/terms from that Manual are used in Electro FORTH, but I love the sound of that VLIST command!  ;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

Executioner

I can't remember the exact version of Forth, but I think it was Forth-79 compatible. If you find a book on the Forth language it should be enough to get you going. There are also some CPC specific routines included (as mentioned, use VLIST).

AMSDOS

#30
I forgot I actually had a book on Forth, unfortunately it appears to be for MMSFORTH for the TRS-80 computers and the syntax in that differs from Electro Forth! :(

So something like this doesn't work  :(


:AGAIN CR " TRY AGAIN" Y/N DUP DUP ;


I changed it to

:AGAIN CR ." TRY AGAIN" Y/N DUP DUP ;

but then it didn't understand Y/N  ???

Here's the rest of the program though, I have a feeling though this is Forth programming prior to the FORTH-79 standard, there's a page about this at the back of the book, so it may seem that a lot of this code maybe MMSForth Based. Very misleading given the book is called "Introduction to Forth"


: TASK ; 1 VARIABLE GUESS
0 VARIABLE LOW 101 VARIABLE HIGH
: AGAIN   CR " TRY AGAIN" Y/N DUP DUP ;
: LOWER   DUP HIGH ! LOW @ DUP ROT SWAP - 2 / +
          SWAP DROP DUP . 1 GUESS +! ;
: HIGHER  DUP LOW ! HIGH @ DUP ROT - 2 / -
          SWAP DROP DUP . 1 GUESS +! ;
: GET    CR " HOW'D I DO" #IN CR ;
: TELL   GET DUP IF 1 - IF CR " ! GUESSED IT IN "
         GUESS ? " TRIES" 1 ELSE LOWER 0 THEN
         ELSE DROP HIGHER 0 THEN ;
: TRY-AGAIN  BEGIN TELL END AGAIN
             0= IF 101 HIGH ! 0 LOW ! 1 GUESS !
             ELSE 1 THEN ;
: COMPGUESS  BEGIN CR 50 DUP . TRY-AGAIN END DROP ;
COMPGUESS  FORGET TASK
* 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

Executioner

It's been a long time since I wrote it or used it. It's not a bad language if you don't mind everything being backwards because it's stack based  :-\

AMSDOS

Understand your predicament, I'm still trying to come to grips with how I wrote some of my assembly routines.

Unfortunately while Forth looks like a decent language, it's the layout which is troubling me. Probably because it's a language which needs constant use to really get a handle of it. Don't really expect the Forth example I posted earlier to be translated unless on the off chance one of the Forth programs on the Amstrad knows that Dialect. Always tricky to tell.
* 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

Executioner

Part of the beauty of Forth though is that if a command doesn't exist, you can create it. It may well be possible to create a Y/N command that does something like:

:Y/N INPUT "Y" = ;

AMSDOS

Ah yes, how could I forget that!  :)
* 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

TFM

Quote from: TFM/FS on 17:48, 14 October 10
... one question remains... which is the most quick Forth for the CPC?

I did a simple speed test, using the following program:

: SQUARE CLS 250 150 ORIGIN
  100 0
  DO 100 0
     DO I J PLOT
     LOOP
  LOOP ;
Now use SQUARE and measure the time...

1. ams-Forth: - doesn't support commands!
2. Electro Forth: 11.3 seconds
3. FIG-Forth: 7.5 seconds
4. volksForth: ? n.d.
5. BASIC need 34.34 seconds!

Tried it just for fun with my plot routine from the FIOLIB, there it's only <0.4 seconds ;-)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

AMSDOS

Quote from: TFM/FS on 17:48, 14 October 10
... one question remains... which is the most quick Forth for the CPC?

I did a simple speed test, using the following program:

: SQUARE CLS 250 150 ORIGIN
  100 0
  DO 100 0
     DO I J PLOT
     LOOP
  LOOP ;
Now use SQUARE and measure the time...

1. ams-Forth: - doesn't support commands!
2. Electro Forth: 11.3 seconds
3. FIG-Forth: 7.5 seconds
4. volksForth:


Just wondered which FIG-Forth that was? There seems to be two the later being Interceptor Software in 1985 & the earlier AMSOFT/Abersoft one or do they share that 7.5 Second Result?  ???
* 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

AMSDOS

Can't believe it's been a few years since I've gone back to Forth.


I went back to an early programming series on Forth ACU had when it went from the transition from Amstrad CPC464 User to ACU. I wasn't entirely clear which Forth Language they might have been referring to and just looking at their opening series, it appears they have some flaws in it, if they were based on the AMSOFT/Abersoft FIG-FORTH. I downloaded the Inceptor Software FIG-FORTH, though also had problems. So I went back to the AMSOFT/Abersoft one, incidentally I downloaded the CDT FORTH from AMSOFT/Indescomp category and discovered it was the AMSOFT/Abersoft version on Tape (obviously repackaged for Spainish users), after looking through the English manual, I don't know if the article (I was just looking at their 1st part from March 1985) has made any errors in their coding. Their 1st example for example takes this BASIC program:



10 LET x = 7
20 PRINT x
30 PRINT CHR$(x)



they write it like this in Forth:



VARIABLE BEEP
7 BEEP !
BEEP @.
BEEP @EMIT



their second line 7 BEEP ! is the same as LET x=7 in BASIC, but I found this is valid in Forth:



7 VARIABLE BEEP
BEEP @ .
BEEP @ EMIT



Which works in AMSOFTs Fig-Forth. Take note Fig-Forth makes a big deal about Spaces, the 1st Forth Example I typed in is how it was written in the ACU article, which does not seperate the "at" symbol from the "full-stop". My 1st line "7 VARIABLE BEEP" simply declares a variable BEEP and assigns 7 to it, which was what I learned from their manual.


Further into the 1st Article ACU have, they posted another Test example that you can try once you've loaded your Forth from Tape, which that too has Spacing issues which Fig-Forth doesn't like, this is what they had:


:TEST100 0 DO ."HELLO" LOOP;


when I typed that in it did not give me "ok", so again look at the Manual and sure enough revealed some vital spaces were missing, I also had to insert spaces in the inverted commas or there would be trouble, eventually I ended up with this that works:



: TEST 100 0 DO ." HELLO " LOOP ;



IT WORKS, yay!!  :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

Powered by SMFPacks Menu Editor Mod