Originally published on: Tue, 04 Aug 2009 02:47:56 +0000
I needed a little mental exercise tonight, so I chose to write a quine ( a program that produces its own source as its output ) in the Forth programming language?
Why Forth? Because I'm a novice Forth programmer at best. I don't think very well in Forth, so this took some effort. Here's the quine: ( the source for this quine is in the public domain )
I tested the above in immediate mode in Win32Forth.
The first portion:
s" ... to the ending " leaves the address and length of a counted string on the stack. By following that with swap dup 1, I was able to make a counted version of the string with a length of 1. A call to the type word then displays the letter "s" from the beginning of the string "swap".
emit 34 emit 32 causes a double-quote and a space to appear. So, the only thing I have left to do is to display the string, a dquote and the string again and I'm done.
I do that by using the remaining code over over swap type 34 emit 32 emit swap type.
Unless otherwise noted, all code and text entries are Copyright ©2009 by James K. Lawless
Views expressed in this blog are those of the author and do not necessary reflect those of the author's employer. Views expressed in the comments are those of the responding individual.

Save to StumbleUpon
Digg it
Save to Reddit
Share on Facebook
Share on Twitter
More bookmarks
Click **here**
A JavaScript REPL for Android Devices
A Review of Kevin Mitnick's Book Ghost in the Wires
Play MP3 Files with Python on Windows
A Simple Parser for a Small Command Line Interface
A Review of Kevin Mitnick's Book Ghost in the Wires
Tracing XSLT with a Tiny Java Web Server
Setting Text Color in a Batch File
Play MP3 Files with Python on Windows
BPL: Batch Programming Language Interpreter
Understanding TRS-80 CMD Files
Why Some Web Sites will go Dark on Jan 18th
Book Review : Paull Allen - Idea Man
A 90's Experiment in Online Systems - The U.S. West CommunityLink Service