flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > RetroForth

Goto page 1, 2, 3  Next
Author
Thread Post new topic Reply to topic
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 07 Jun 2005, 23:21
I guess I can share my project here too... So here's some shameless self-promotion: Wink

RetroForth is an implementation of the Forth programming language. For those who don't know about it, I'll share a few of the implementation details.

RetroForth is based on a small core written in FASM. This is about 800 lines of assembly, including macros, blank lines, and comments. In that space I implement an interpreter, a compiler, and some basic console I/O functions on which the majority of the Forth language can be built. Upon startup, this core compiles some bootstrap code (under 4k of source). The entire startup process takes about 0.035 seconds on my machine.

Main Features:
* Core written in FASM
* Built in editor [new in Version 8]
* Small size: 8-10k, including the bootstrap code
** Core compiles to about 2k of binary code
** The rest is the bootstrap code
* Library of standard extensions
* Documentation covering all functions in the core and bootstrap code
* Most bugs get fixed within 24 hours of reporting
* Rapid release cycle
* Good support
* Runs on Windows, Linux, BSD, BeOS, SCO OpenServer, Dex4u, and more
** Use any Linux system call or most DLL's under Windows
** Also has a native version that runs as an OS

See http://www.retroforth.org for more details or http://retro.tunes.org to download a copy of the latest release.

(As a side note I'm now coding an optimization library that will let the compiled code approach the quality of hand-coded assembly) Very Happy[/i]
Post 07 Jun 2005, 23:21
View user's profile Send private message Visit poster's website Reply with quote
ronware



Joined: 08 Jan 2004
Posts: 179
Location: Israel
ronware 08 Jun 2005, 00:35
Slow Smile

Reva reports 0.00 seconds startup on my machine:

Code:
echo bye | time bin/reva
    


But that make sense, since Reva is essentially RetroForth with almost everything in the assembly core.
Post 08 Jun 2005, 00:35
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 08 Jun 2005, 01:01
Heh, on my box that takes 0.002 for Reva. But it is true... you don't compile almost everything on startup, so I feel that my performance is respectable. :p
Post 08 Jun 2005, 01:01
View user's profile Send private message Visit poster's website Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 08 Jun 2005, 13:13
Hi crc,
I'd like to learn (at least some basics) how to program in RetroForth. Are there any tutorials about RF syntax available? Where could I find any info? I don't even know how to write simple "hello world" program Wink
Post 08 Jun 2005, 13:13
View user's profile Send private message Visit poster's website Reply with quote
ronware



Joined: 08 Jan 2004
Posts: 179
Location: Israel
ronware 08 Jun 2005, 15:17
decard -

Just start rf and type in:

Code:
." hello world" cr
    


That's it. The Reva site (and esp. the zip file) has documentation. crc is still working on the docs for rf last I heard (some of them are based on mine -- we tend to share a lot of ideas and code)
Post 08 Jun 2005, 15:17
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
crc_at_work
Guest




crc_at_work 08 Jun 2005, 18:40
decard, take a look at http://www.retroforth.org/handbook

There is now a tutorial (in progress, but enough to teach the basics) in place Smile
Post 08 Jun 2005, 18:40
Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 09 Jun 2005, 14:05
Thanks, I will take a look Wink
Post 09 Jun 2005, 14:05
View user's profile Send private message Visit poster's website Reply with quote
Guest





Guest 09 Jun 2005, 18:09
RetroFORTH looks interesting but is it useful? How do you use it, and what do you use it for?
Post 09 Jun 2005, 18:09
Reply with quote
THEWizardGenius



Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius 09 Jun 2005, 18:11
Sorry, that was me: I forgot to login. One more thing:
Is it possible to access outside things such as interrupts to BIOS API or port IN/OUT instructions? It would be nice to be able to do more than arithmetic, conditionals, looping, strings, and numbers. For example, if you allowed port I/O and/or interrupts (to BIOS APIs, etc.) then a RF program could print to the printer. This sort of thing would be really nice.
Is this or something similar possible in RF?
Post 09 Jun 2005, 18:11
View user's profile Send private message AIM Address Reply with quote
Kain



Joined: 26 Oct 2003
Posts: 108
Kain 09 Jun 2005, 22:43
Don't know much forth, but I managed to crash it while poking around.

."

Type just the above and press enter. I'm on WinXP

is forth an interpreted language?
Post 09 Jun 2005, 22:43
View user's profile Send private message Reply with quote
ronware



Joined: 08 Jan 2004
Posts: 179
Location: Israel
ronware 09 Jun 2005, 22:59
It's both interpreted and compiled. When you type in ." the interpreter parsed off the "word" .". It then executed that word. As it turns out, ." is itself a parsing word, which looks ahead until it finds a matching ". In your case, this caused a crash for some reason.

Interestingly, I just tried this in Reva on both Linux and Windows and it did not crash - but I don't guarantee that result!
Post 09 Jun 2005, 22:59
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 09 Jun 2005, 23:00
Quote:
Don't know much forth, but I managed to crash it while poking around.

."

Type just the above and press enter. I'm on WinXP

is forth an interpreted language?


It is easy to crash most Forth systems, including RetroForth. It's a lot like assembly: if you do something wrong, your app will crash. Smile

Forth is sort of odd; it's both interpreted and compiled. Basically it has an interpreter mode where you can type code and have it run interactively. There's also a compiler which allows you to extend the language and syntax at runtime. This combination is very powerful and allows a lot of flexibility.
Post 09 Jun 2005, 23:00
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 09 Jun 2005, 23:14
Quote:
... is it useful? How do you use it, and what do you use it for?


I find it to be very useful. (Indeed, outside of a bit of assembly coding, I seldom use any other language now). RetroForth is turing complete, for what that's worth. Actually, it's not too much higher than assembly language.

It's generally used interactively. You can type commands (words) at the interpreter, and define new ones there too. There is also an editor that you can interact with. Learning the ropes isn't too hard. It's a lot like the old Lisp systems used to be: a highly interactive, highly integreted environment.

I use it for most of my coding. Some of the apps I've written (or am writing) include an irc client (for Linux), an interactive fiction game, simple servers (echo server is done, chat server in progress, ultimate goal is a mud server), a debugger (including a simple disassembler), command-line shells for Linux and Windows, timecard calculator, inventory management software, and various custom database apps. I've also written a couple of editors, and am working on a simple assembler to go with the debugger.

Others have done more visually impressive things with it. Some of the users have developed libSDL, Allegro, and OpenGL-based demos, and even delved into audio. Soon I'll have callbacks in place which will allow you to use more of the Win32 API and even GTK. It's really quite flexible Wink
Post 09 Jun 2005, 23:14
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 09 Jun 2005, 23:40
THEWizardGenius: There are various ways to interact with the system, but it depends on the port of RetroForth you're using.

On Native and L4, you can use port I/O freely. The BIOS functions aren't supported as there's no vm86 mode.

On Linux (and soon Dex4u) you can use any system call

On Windows you can use most functions in most dll's

I can post some examples if you'd like me to.
Post 09 Jun 2005, 23:40
View user's profile Send private message Visit poster's website Reply with quote
THEWizardGenius



Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius 14 Jun 2005, 23:33
I tried out the Windows version but it doesn't support any of the editor commands or anything else. Where is this editor?\

Also, I'd like to use the Native version but it's in .tar.gz and I don't have Linux. I searched and finally found a DOS thing for those but then I couldn't figure how to set it up! Can you put it in ZIP for us Windows users, and can you also make an installation program or give a link to a program that can be used to do this for Windows?

Other than this I have no complaints, I liked RF even though I couldn't do much. Now having used it and reading the manual further I understand that it's in pmode, but I see no port I/O instructions in the manual? Can you tell me what they are?
Post 14 Jun 2005, 23:33
View user's profile Send private message AIM Address Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 14 Jun 2005, 23:36
wizard, grab hold of WinRAR at http://www.rarlabs.com - it's very nice, and supports a lot of different archive types. One of the programs that is well worth registering Smile
Post 14 Jun 2005, 23:36
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 14 Jun 2005, 23:53
TheWizardGenius: which version of RetroForth for Windows did you try?
Post 14 Jun 2005, 23:53
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 15 Jun 2005, 00:25
There are four words used to read/write to ports. These are:

Code:
p1@   read a byte from a port
p2@   read a word from a port
p1!   write a byte to a port
p2!   write a word to a port    


Code:
| An example of reading a port:
$12 p1@ .  | read a byte from port 0x12
$25 p2@ .  | read a word from port 0x25    


Code:
| An example of writing to a port:
96 $12 p1! .  | write a byte (96) to port 0x12
31 $25 p2! .  | write a word (31) to port 0x25    


While I haven't fully tested this yet, here's a minimal serial port driver using these words. This will be added to RetroForth/Native later this week:

Code:
: COM1 $3F8 ;
: COM2 $2F8 ;
: COM3 $3E8 ;
: COM4 $2E8 ;

COM2 variable: SERIAL-PORT

: com# SERIAL-PORT @ ;
: serial-init
  $0  com# 1 + p1!  $80 com# 3 + p1!
  $03 com# 0 + p1!  $0  com# 1 + p1! 
  $03 com# 3 + p1!  $C7 com# 2 + p1! 
  $0B com# 4 + p1!  ;
: serial-received? com# 5 + p1@ 1 and ;
: transmit-empty? com# 5 + p1@ $20 and ;
: read.serial serial-received? 0 <>if com# p1@ ;; then read.serial ;
: write.serial transmit-empty? 0 <>if com# p1! ;; then write.serial ;
: type.serial for dup c@ write.serial 1+ r> next drop ;    
Post 15 Jun 2005, 00:25
View user's profile Send private message Visit poster's website Reply with quote
Guest





Guest 17 Jun 2005, 03:47
Cool, but you'd probably want IRQ-handler capabilities in RF. I just got the stable release 7.6 (from http://www.retroforth.org/) as I said, the Windows one. BTW f0dder I'm just a kid (14) so I don't have any money at all.
Post 17 Jun 2005, 03:47
Reply with quote
THEWizardGenius



Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius 17 Jun 2005, 03:49
Oops forgot to log in...
Post 17 Jun 2005, 03:49
View user's profile Send private message AIM Address Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2, 3  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.