floate.h locals.h localse.h macro.h memall.h search.h searche.h \
string.h tools.h toolse.h udio.h ver.h ycore.h yforth.h
-all:
- make div
- make yforth
-
-yforth: $(OBJECTS)
+yforth: div.h $(OBJECTS)
$(CC) $(MATHLIB) -o yforth $(OBJECTS)
+div.h: div
+ ./div
+
div: division.c
$(CC) -o div division.c
- div > div.h
.c.o:
$(CC) -c -o $@ $(OPTIMIZE) $<
-yForth? v0.1beta - READ THIS (AND ONLY THIS) TO GET yForth? RUNNING.
+yForth? v0.1+beta - READ THIS (AND ONLY THIS) TO GET yForth? RUNNING.
0) Hello world!
Here's a little file which will help you having yForth? running in few
together in the file "udio.c". If you're using Turbo C, Borland C, or any
compiler which supplies the "conio.h", you can define HAVE_CONIO in
your "config.h" file and go.
-Note that even if in file "udio.c" you'll see some lines telling you:
-#ifdef HAVE_CURSES
-or similar, yForth? actually doesn't support CURSES library. I've decided to
-stop my work as soon as something machine depended that was too messy has
-came around.
2) Where does the name yForth? came from?
I've been charmed by Forth since the first time I "played" with it, but
Below data definition you'll have to change the maximum values of your
system. See "limits.h".
- terminal
-Finally, define HAVE_CONIO if you're using Turbo C, Borland C or GCC for DOS.
-You'll have some nice words such as "page"...
+Finally, define HAVE_CONIO to 1 if you're using Turbo C, Borland C or GCC
+for DOS. You'll have some nice words such as "page"...
- special functions
"asinh", "acosh", "atanh" aren't provided by all the libraries, if you don't
-have them delete the definitions at the end of "config.h".
+have them reset the definitions at the end of "config.h".
-The second thing to do now is configuring the "Makefile". I know, it's rude,
-but yForth? is drifting on my system for too long, I want to finish it
-within 1996.
-At the moment "Makefile" is ready for GCC (under Linux), it's simple and
-you won't find any problem modifying it.
+The second thing to do now is configuring the "Makefile". At the moment
+"Makefile" is ready for GCC (under Linux), it's simple and you won't find any
+problem modifying it.
Third, type "make all". Yes, that's all.
email: lpadovan@cs.unibo.it
Enjoy yForth?
+
+**********************************************************************
+ CONTRIBUTORS
+**********************************************************************
+
* excluded word lists may be linked to final code if used by other words.
*/
+#include <endian.h>
+
#define COREE_DEF 1L
#define DOUBLE_DEF 1L
#define DOUBLEE_DEF 1L
* it if your machine is big-endian (e.g. Motorola, Sparc...)
* Note that some compilers have LITTLE_ENDIAN yet defined.
*/
-#ifndef LITTLE_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN
# define LITTLE_ENDIAN
+#else
+# undef LITTLE_ENDIAN
#endif
/* When DCELL_MEM is defined, double cell transfer is realized by memory
* Under Linux, Cell may be "int" and DCell "long long".
*/
-#define Cell int
+/* this might work for other 64 bit architectures, too? */
+#if defined(__alpha__)
+# define Cell long
+#else
+# define Cell int
+#endif /* __alpha__ */
+
#define Char char
-#define Real long double
+#define Real float
#define UCell unsigned Cell
#define DCell long long
#define MAX_F 0.0
/* Some compilers doesn't provide some functions in the standard library.
- * If you don't have, undefine them
- */
-#define HAVE_ACOSH
-#define HAVE_ASINH
-#define HAVE_ATANH
+ * If you don't have, turn 1s into 0s
+ */
+#define HAVE_ACOSH 1
+#define HAVE_ASINH 1
+#define HAVE_ATANH 1
+
+/* Set following define to 1 if you're compiling under Turbo C, Borland C,
+ * or GCC for DOS.
+ */
+#define HAVE_CONIO 0
}
void _parse() {
- register Char delim = (Char) *sp;
+ register Char delim = (Char) *sp;
register Char *orig = &_input_buffer[_to_in];
register int i = 0;
while (_to_in < _in_input_buffer && _input_buffer[_to_in] != delim) {
_to_in++;
i++;
}
- *sp = (Cell) orig;
+ *sp = (Cell)orig;
*--sp = i;
+
if (_to_in < _in_input_buffer) _to_in++;
}
code(unused, "unused", 0)
code(within, "within", 0)
code(backslash, "\\", IMMEDIATE)
+code(backslash, "#!", IMMEDIATE)
code(bracket_compile, "[compile]", COMP_ONLY)
code(value, "value", 0)
code(to, "to", IMMEDIATE)
--- /dev/null
+yforth for DEBIAN
+----------------------
+
+This is a small implementation of the better part of the ANS Forth core
+standard. It is less appropriate for hacking Forth scripts under Linux than,
+say, gforth... but it has great promise, and I'm sufficiently interested in
+playing with it for embedded environments that I've decided to go ahead and
+package it.
+
+The author says it's "freeware", and you can do anything you want with it,
+unencumbered even by the GPL. Enjoy.
+
+
+Bdale Garbee <bdale@gag.com>, Sat, 1 Feb 1997 20:18:18 -0700
--- /dev/null
+yforth (0.1beta-15) unstable; urgency=low
+
+ * add amd64 to control file, closes: #252783
+
+ -- Bdale Garbee <bdale@gag.com> Wed, 9 Jun 2004 13:23:55 -0600
+
+yforth (0.1beta-14) unstable; urgency=low
+
+ * patch from David N. Welton to make things work on big-endian machines
+ like powerpc, closes: #96207
+ * a few cleanups to make lintian happier
+
+ -- Bdale Garbee <bdale@gag.com> Mon, 7 May 2001 10:45:21 -0600
+
+yforth (0.1beta-13) unstable; urgency=low
+
+ * patch from Chris Chimelis to work on alpha architecture, closes: #65407
+
+ -- Bdale Garbee <bdale@gag.com> Sun, 18 Jun 2000 21:57:21 -0600
+
+yforth (0.1beta-12) unstable; urgency=low
+
+ * lose the dh_du call, closes: #51484
+ * update to latest policy
+
+ -- Bdale Garbee <bdale@gag.com> Sun, 5 Dec 1999 09:55:40 -0700
+
+yforth (0.1beta-11) frozen unstable; urgency=low
+
+ * Hartmut reminds me that yforth compiles and runs on powerpc as well.
+
+ -- Bdale Garbee <bdale@gag.com> Tue, 26 Jan 1999 21:02:28 -0700
+
+yforth (0.1beta-10) frozen unstable; urgency=low
+
+ * update control file to account for yforth not working on 64 bit machines.
+ Instead of 'any', specify i386/m68k/sparc/arm. I *think* all of those
+ should work. Update documentation to include my best contact info for
+ the upstream author, and acknowledge that there is no longer an upstream
+ site for this package. Closes 32413.
+
+ -- Bdale Garbee <bdale@gag.com> Tue, 26 Jan 1999 09:18:24 -0700
+
+yforth (0.1beta-9) frozen unstable; urgency=low
+
+ * return 0 on successful completion of main() in division.c, closes 32217
+
+ -- Bdale Garbee <bdale@gag.com> Fri, 22 Jan 1999 10:34:14 -0700
+
+yforth (0.1beta-8) frozen unstable; urgency=low
+
+ * fix a problem in the Makefile, closes 30065.
+
+ -- Bdale Garbee <bdale@gag.com> Tue, 15 Dec 1998 00:18:52 -0700
+
+yforth (0.1beta-7) frozen unstable; urgency=low
+
+ * patch to Makefile from James Troup so '.' doesn't need to be in PATH,
+ closes 20990
+
+ -- Bdale Garbee <bdale@gag.com> Sat, 11 Apr 1998 12:37:39 -0600
+
+yforth (0.1beta-6) frozen unstable; urgency=low
+
+ * fix typos in description, closes 19007.
+
+ -- Bdale Garbee <bdale@gag.com> Fri, 3 Apr 1998 22:20:45 -0700
+
+yforth (0.1beta-5) unstable; urgency=low
+
+ * change from debmake to debhelper
+ * fix errors and warnings from lintian
+
+ -- Bdale Garbee <bdale@gag.com> Mon, 9 Feb 1998 22:17:38 -0700
+
+yforth (0.1beta-4) unstable; urgency=low
+
+ * libc6
+
+ -- Bdale Garbee <bdale@gag.com> Thu, 4 Sep 1997 03:19:14 -0600
+
+yforth (0.1beta-3) unstable; urgency=low
+
+ * Luca accepted my patch, and sent me back some other tweaks...
+
+ -- Bdale Garbee <bdale@gag.com> Wed, 5 Feb 1997 08:08:58 -0700
+
+yforth (0.1beta-2) unstable; urgency=low
+
+ * Hack in "#!" as an alias for "\" to allow yforth to be used as a script
+ interpreter.
+
+ -- Bdale Garbee <bdale@gag.com> Sun, 2 Feb 1997 12:07:13 -0700
+
+yforth (0.1beta-1) unstable; urgency=low
+
+ * Initial Release.
+
+ -- Bdale Garbee <bdale@gag.com> Sat, 1 Feb 1997 20:18:18 -0700
+
+Local variables:
+mode: debian-changelog
+End:
--- /dev/null
+Source: yforth
+Section: interpreters
+Priority: extra
+Maintainer: Bdale Garbee <bdale@gag.com>
+Build-Depends: debhelper
+Standards-Version: 3.6.1.0
+
+Package: yforth
+Architecture: alpha amd64 arm i386 m68k powerpc sparc
+Depends: ${shlibs:Depends}
+Description: A small freeware Forth environment in ANSI C
+ yForth? is an interestingly small implementation of Forth for Linux. It
+ suffers several deficiencies. For general Forth programming or learning
+ under Linux, yForth? is not the best choice.
+ .
+ From the author's README:
+ .
+ yForth? is a Forth environment written entirely in ANSI C, making it
+ extremely portable. The first thing I want to tell you about yForth? is
+ that it seems a joke compared to other systems such as gForth or PFE.
+ .
+ Nevertheless, you could find yForth? nice, in which case you're invited to
+ explore yForth?
+ .
+ It's yours, you can make anything you want with it. If you want an explanation
+ of the words provided by yForth? please refer to the draft of ANS Forth or
+ something equivalent. The Net will help you.
+ .
+ Do not expect the prompt "ok" to come up when you run yForth?, the standard
+ says that "ok" shall be printed AFTER every successful command execution...
--- /dev/null
+This package was debianized by Bdale Garbee bdale@gag.com on
+Sat, 1 Feb 1997 20:18:18 -0700.
+
+The sources were retrieved from http://www.cs.unibo.it/~lpadovan/.
+
+It is not clear that Luca still maintains or develops yforth, as his web page
+now just points to the Debian distribution for those interested in yforth.
+
+Written by
+
+ Luca Padovani
+ v. Cormons, 12
+ 48100 Ravenna (RA)
+ Italy
+
+ email: lpadovan@cs.unibo.it
+
+Copyright:
+
+/* yForth? - Written by Luca Padovani (C) 1996/97
+ * ------------------------------------------------------------------------
+ * This software is FreeWare as long as it comes with this header in each
+ * source file, anyway you can use it or any part of it whatever
+ * you want. It comes without any warranty, so use it at your own risk.
+ * ------------------------------------------------------------------------
+ */
--- /dev/null
+#!/usr/bin/make -f
+# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
+
+# WARNING - the makefile for this package is not SMP-safe! Don't try
+# to build this package with 'make -j'
+
+# Uncomment this to turn on verbose mode.
+export DH_VERBOSE=1
+
+build: build-stamp
+build-stamp:
+ dh_testdir
+ $(MAKE)
+ touch build-stamp
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp
+ -$(MAKE) clean
+ dh_clean
+
+# Build architecture-independent files here.
+binary-indep: build
+
+# Build architecture-dependent files here.
+binary-arch: build
+# dh_testversion
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ install -g root -m 755 -o root yforth debian/tmp/usr/bin/yforth
+
+ dh_installdocs
+ dh_installexamples
+ dh_installmenu
+# dh_installinit
+ dh_installcron
+ dh_installmanpages
+# dh_undocumented
+ dh_installchangelogs
+ dh_strip
+ dh_compress
+ dh_fixperms
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+# dh_makeshlibs
+ dh_md5sums
+ dh_builddeb
+
+source diff:
+ @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary
#include <stdio.h>
-main() { printf("#define FLOORED_DIVISION %d\n", (-10 % 7) > 0 ? 1 : 0); }
+#include <math.h>
+#include <assert.h>
+
+main() {
+ FILE *f = fopen("div.h", "wt");
+ assert(f != NULL);
+ fprintf(f, "#define FLOORED_DIVISION %d\n", (-10 % 7) > 0 ? 1 : 0);
+ fclose(f);
+ return 0;
+}
/**************************************************************************/
Cell truncate_file(FILE *f, UDCell cur, UDCell ud) {
- if (cur == cur && fseek(f, ud, SEEK_SET)) return (errno);
+ if (fseek(f, ud, SEEK_SET)) return (errno);
else return (0);
}
--- /dev/null
+#! /usr/bin/yforth
+\
+\ a simple example of a yforth script
+\
+.( Hello World!) cr bye
*/
#include "yforth.h"
-#ifdef HAVE_CONIO
+#if HAVE_CONIO
# include <conio.h>
-#elifdef HAVE_CURSES
-# include <curses.h>
#endif
#include "udio.h"
/* d_clrscr: clear the screen */
void d_clrscr() {
-#ifdef HAVE_CONIO
+#if HAVE_CONIO
clrscr();
-#elifdef HAVE_CURSES
- clear();
#endif
}
/* d_clreol: clear to end of line */
void d_clreol() {
-#ifdef HAVE_CONIO
+#if HAVE_CONIO
clreol();
-#elifdef HAVE_CURSES
- clrtoeol();
#endif
}
/* d_setattr: set default attributes */
void d_setaddr(Cell attr) {
-#ifdef HAVE_CONIO
+#if HAVE_CONIO
textattr(attr);
-#elifdef HAVE_CURSES
#endif
}
/* d_getattr: get default attributes */
Cell d_getattr() {
-#ifdef HAVE_CONIO
+#if HAVE_CONIO
struct text_info ti;
gettextinfo(&ti);
return (ti.attribute);
-#elifdef HAVE_CURSES
#endif
}
/* d_gotoxy: move the cursor to the location (x, y) of the screen */
void d_gotoxy(Cell x, Cell y) {
-#ifdef HAVE_CONIO
+#if HAVE_CONIO
gotoxy(x, y);
-#elifdef HAVE_CURSES
- move(y, x);
#endif
}
/* d_wherex: current column position of the cursor */
Cell d_wherex() {
-#ifdef HAVE_CONIO
+#if HAVE_CONIO
return (wherex());
-#elifdef HAVE_CURSES
- int x, y;
- getyx(stdscr, y, x);
- return ((Cell) x);
#endif
}
/* d_wherey: current row position of the cursor */
Cell d_wherey() {
-#ifdef HAVE_CONIO
+#if HAVE_CONIO
return (wherey());
-#elifdef HAVE_CURSES
- int x, y;
- getyx(stdscr, y, x);
- return ((Cell) y);
#endif
}
* Return
*/
Char d_getch() {
-#ifdef HAVE_CONIO
- return (getch());
-#elifdef HAVE_CURSES
+#if HAVE_CONIO
return (getch());
#endif
}
/* d_kbhit: return True if a character is available */
Cell d_kbhit() {
-#ifdef HAVE_CONIO
+#if HAVE_CONIO
return (kbhit());
-#elifdef HAVE_CURSES
- return (1);
-#endif
+#endif
}
/* d_open: Initialize the Input/Output device */
void d_open() {
-#ifdef HAVE_CURSES
- initscr();
- cbreak();
- noecho();
- nonl();
- /* intrflush(stdscr, FALSE); */
- /* keypad(stdscr, TRUE); */
-#endif
-}
+}
/* d_close: make some work when program finish to restore Input/Output device */
void d_close() {
-#ifdef HAVE_CURSES
- endwin();
-#endif
}
#define VER_HI 0
#define VER_LO 1
-#define VER_TEST "beta"
+#define VER_TEST "+beta"
--- /dev/null
+.TH YFORTH 1
+.SH NAME
+yforth \- a small, free Forth implementation
+.SH SYNOPSIS
+.B yforth
+.SH DESCRIPTION
+This is a small implementation of the Forth programming language, somewhat
+easier to read than larger Forth implementations like Gforth.
+
+It is not being actively developed or maintained. If you find it useful,
+great. If not, don't expect much help. The www.forth.org site is a good
+place to get more general information on Forth.
+
+Serious Forth authors would be advised to use Gforth instead of this package.
+
+.SH AUTHOR
+This man page was cobbled up for the Debian distribution by Bdale Garbee.
# define GET_DCELL(ptr) get_dcell((Cell *) ptr)
# define PUT_DCELL(ptr, d) put_dcell((Cell *) ptr, (DCell) d)
# else
-# define GET_DCELL(ptr) *((DCell *) ptr)
-# define PUT_DCELL(ptr, d) *((DCell *) ptr) = d
+# define GET_DCELL(ptr) *((DCell *) (ptr))
+# define PUT_DCELL(ptr, d) *((DCell *) (ptr)) = d
# endif
#else
# ifdef LITTLE_ENDIAN