-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathdpans94.txt
10134 lines (9851 loc) · 606 KB
/
dpans94.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
ANSI X3.215-1994
American National Standard
for Information Systems --
Programming Languages ---
Forth
Secretariat
Computer and Business Equipment Manufacturers Association
Approved: March 24, 1994
American National Standards Institute, Inc.
1
ANSI X3.215-1994
Copyright (c) 1994 by Technical Committee X3J14. All rights reserved.
This is a working document of Technical Committee X3J14 which represents the last draft of
ANS Forth submitted to ANSI for publication. Permission is hereby granted to copy this
document provided that it is copied in its entirety without alteration or as altered by
(1) adding text that is clearly marked as an insertion; (2) shading or highlighting
existing text; and/or (3) deleting examples.
Specifically, permission is granted to use this working document as the foundation for
textbooks, system manuals, and online documentation so long as the requirements in the
preceding paragraph are met and the resulting product addresses a technical need that is
not practically met by the official ANS.
NOTE: This file is provided as a working document of the TC for public review and comment
as well as documentation uses described above. It is not intended as a substitute for the
official ANS Forth document published by ANSI. In the event of conflict, only the printed
document X3.215-1994 represents the official ANS Forth.
To obtain the official standard, please contact the American National Standards Institute
Sales Department, at (212) 642-4900 or FAX (212) 302-1286, or Global Engineering
Documents, at (800) 854-7179 or FAX (303) 843-9880, and request Document X3.215-1994.
Thank you very much for your interest.
2
ANSI X3.215-1994
CONTENTS
Foreword ........................................................ 6
X3 Membership ................................................... 7
X3J14 Membership ................................................ 9
1. Introduction .............................................. 11
1.1 Purpose ................................................. 11
1.2 Scope ................................................... 11
1.2.1 Inclusions ............................................ 11
1.2.2 Exclusions ............................................ 11
1.3 Document organization ................................... 12
1.3.1 Word sets ............................................. 12
1.3.2 Annexes ............................................... 12
1.4 Future directions ....................................... 13
1.4.1 New technology ........................................ 13
1.4.2 Obsolescent features .................................. 13
2. Terms, notation, and references ........................... 14
2.1 Definitions of terms .................................... 14
2.2 Notation ................................................ 17
2.2.1 Numeric notation ...................................... 17
2.2.2 Stack notation ........................................ 17
2.2.3 Parsed-text notation .................................. 18
2.2.4 Glossary notation ..................................... 18
2.3 References .............................................. 19
3. Usage requirements ........................................ 20
3.1 Data types .............................................. 20
3.1.1 Data-type relationships ............................... 20
3.1.2 Character types ....................................... 21
3.1.3 Single-cell types ..................................... 23
3.1.4 Cell-pair types ....................................... 24
3.1.5 System types .......................................... 24
3.2 The implementation environment .......................... 25
3.2.1 Numbers ............................................... 25
3.2.2 Arithmetic ............................................ 26
3.2.3 Stacks ................................................ 27
3.2.4 Operator terminal ..................................... 28
3.2.5 Mass storage .......................................... 28
3.2.6 Environmental queries ................................. 28
3.3 The Forth dictionary .................................... 29
3.3.1 Name space ............................................ 29
3.3.2 Code space ............................................ 30
3.3.3 Data space ............................................ 30
3.4 The Forth text interpreter .............................. 32
3.4.1 Parsing ............................................... 33
3.4.2 Finding definition names .............................. 34
3.4.3 Semantics ............................................. 34
3.4.4 Possible actions on an ambiguous condition ............ 35
3.4.5 Compilation ........................................... 35
4. Documentation requirements ................................ 36
4.1 System documentation .................................... 36
4.1.1 Implementation-defined options ........................ 36
3
ANSI X3.215-1994
4.1.2 Ambiguous conditions .................................. 37
4.1.3 Other system documentation ............................ 38
4.2 Program documentation ................................... 38
4.2.1 Environmental dependencies ............................ 38
4.2.2 Other program documentation ........................... 38
5. Compliance and labeling ................................... 40
5.1 ANS Forth systems ....................................... 40
5.1.1 System compliance ..................................... 40
5.1.2 System labeling ....................................... 40
5.2 ANS Forth programs ...................................... 40
5.2.1 Program compliance .................................... 40
5.2.2 Program labeling ...................................... 40
6. Glossary .................................................. 41
6.1 Core words .............................................. 41
6.2 Core extension words .................................... 64
7. The optional Block word set ............................... 73
8. The optional Double-Number word set ....................... 79
9. The optional Exception word set ........................... 84
10. The optional Facility word set ............................ 49
11. The optional File-Access word set ......................... 93
12. The optional Floating-Point word set ..................... 102
13. The optional Locals word set ............................. 119
14. The optional Memory-Allocation word set .................. 124
15. The optional Programming-Tools word set .................. 127
16. The optional Search-Order word set ....................... 134
17. The optional String word set ............................. 139
A. Rationale (informative annex) ............................ 142
A.1 Introduction ........................................... 142
A.2 Terms and notation ..................................... 144
A.3 Usage requirements ..................................... 145
A.4 Documentation requirements ............................. 159
A.5 Compliance and labeling ................................ 159
A.6 Glossary ............................................... 161
A.7 The optional Block word set ............................ 182
A.8 The optional Double-Number word set .................... 183
A.9 The optional Exception word set ........................ 184
A.10 The optional Facility word set ......................... 188
A.11 The optional File-Access word set ...................... 191
A.12 The optional Floating-Point word set ................... 195
A.13 The optional Locals word set ........................... 199
A.14 The optional Memory-Allocation word set ................ 203
A.15 The optional Programming-Tools word set ................ 203
A.16 The optional Search-Order word set ..................... 206
A.17 The optional String word set ........................... 209
B. Bibliography (informative annex) ......................... 210
C. Perspective (informative annex) .......................... 213
C.1 Features of Forth ...................................... 213
C.2 History of Forth ....................................... 214
C.3 Hardware implementations of Forth ...................... 214
C.4 Standardization efforts ................................ 215
C.5 Programming in Forth ................................... 215
4
ANSI X3.215-1994
C.6 Multiprogrammed systems ................................ 224
C.7 Design and management considerations ................... 224
C.8 Conclusion ............................................. 225
D. Compatibility analysis of ANS Forth (informative annex) .. 226
D.1 FIG Forth (circa 1978) ................................. 226
D.2 Forth 79 ............................................... 226
D.3 Forth 83 ............................................... 226
D.4 Recent developments .................................... 227
D.5 ANS Forth approach ..................................... 228
D.6 Differences from Forth 83 .............................. 228
D.6.1 Stack width .......................................... 228
D.6.2 Number representation ................................ 229
D.6.3 Address units ........................................ 229
D.6.4 Address increment for a cell is no longer two ........ 230
D.6.5 Address alignment .................................... 231
D.6.6 Division/modulus rounding direction .................. 232
D.6.7 Immediacy ............................................ 233
D.6.8 Input character set .................................. 235
D.6.9 Shifting with UM/MOD ................................. 235
D.6.10 Vocabularies / wordlists ............................. 236
D.6.11 Multiprogramming impact .............................. 237
D.6.12 Words not provided in executable form ................ 237
E. ANS Forth portability guide (informative annex) .......... 239
E.1 Introduction ........................................... 239
E.2 Hardware peculiarities ................................. 239
E.2.1 Data/memory abstraction .............................. 239
E.2.2 Definitions .......................................... 239
E.2.3 Addressing memory .................................... 240
E.2.4 Alignment problems ................................... 241
E.3 Number representation .................................. 242
E.3.1 Big endian vs. little endian ......................... 242
E.3.2 ALU organization ..................................... 242
E.4 Forth system implementation ............................ 243
E.4.1 Definitions .......................................... 243
E.4.2 Stacks ............................................... 244
E.5 ROMed application disciplines and conventions .......... 244
E.6 Summary ................................................ 245
F. Alphabetic list of words (informative annex) ............. 246
5
ANSI X3.215-1994
Foreword
(This foreword is not a part of American National Standard X3.215-1994)
Forth is a language for direct communication between human beings and machines. Using
natural-language diction and machine-oriented syntax, Forth provides an economical,
productive environment for interactive compilation and execution of programs. Forth also
provides low-level access to computer-controlled hardware, and the
ability to extend the language itself. This extensibility allows the language to be
quickly expanded and adapted to special needs and different hardware systems.
Forth was invented by Mr. Charles Moore to increase programmer productivity without
sacrificing machine efficiency. Forth is a layered environment containing the elements of
a computer language as well as those of an operating system and a machine
monitor. This extensible, layered environment provides for highly interactive program
development and testing.
In the interests of transportability of application software written in Forth,
standardization efforts began in the mid-1970s by an international group of users and
implementors who adopted the name "Forth Standards Team". This effort resulted in the
Forth-77 Standard. As the language continued to evolve, an interim Forth-78 Standard was
published by the Forth Standards Team. Following Forth Standards Team meetings in 1979,
the Forth-79 Standard was published in 1980. Major changes were made by the Forth
Standards Team in the Forth-83 Standard, which was published in 1983.
The first meeting of the Technical Committee on Forth Programming Systems was convened by
the Organizing Committee of he X3J14 Forth Technical Committee on August 3, 1987, and has
met subsequently on November 11-12, 1987, February 10-12, 1988, May 25-28, 1988, August
10-13, 1988, October 26-29, 1988, January 25-28, 1989, May 3-6, 1989, July 26-29, 1989,
October 25-28, 1989, January 24-27, 1990, May 22-26, 1990, August 21-25, 1990, November 6-
10,1990, January 29-February 2, 1991, May 3-4, 1991, June 16-19, 1991, July 30-August 3,
1991, March 17-21, 1992, October 13-17, 1992, January 26-30, 1993, June 28-30, 1993, and
June 21, 1994.
Requests for interpretation, suggestions for improvement or addenda, or defect reports are
welcome. They should be sent to the X3 Secretariat, Computer and Business Equipment
Manufacturers Association, 1250 Eye Street, NW, Suite 200, Washington, DC 20005.
6
ANSI X3.215-1994
3 Membership
This standard was processed and approved for submittal to ANSI by the Accredited Standards
Committee on Information Processing Systems, X3. Committee approval of this standard does
not necessarily imply that all committee members voted for its approval. At the time it
approved this standard, the X3 Committee had the following members:
James D. Converse, Chair
Donald C. Loughry, Vice-Chair
Joanne Flanagan, Secretary
Producer Group Name of Representative
AMP Incorporated ............................. Edward Kelly
Charles Brill (Alt.)
AT&T/NCR Corporation ......................... Thomas W. Kern
Thomas F. Frost (Alt.)
Apple Computer, Inc. ......................... Karen Higginbottom
Compaq Computers ............................. James Barnes
Digital Equipment Corporation ................ Delbert Shoemaker
Kevin Lewis
Hitachi America Ltd. ......................... John Neumann
Kei Yamashita (Alt.)
Hewlett Packard .............................. Donald C. Loughry
Bull HN Information Systems Inc. ............. William George
IBM Corporation .............................. Joel Urman
Mary Anne Lawler (Alt.)
Unisys Corporation ........................... John Hill
Stephen P. Oksala (Alt.)
Sony Corporation of America .................. Michael Deese
Storage Technology Corporation ............... Joseph S. Zajaczkowski
Samuel D. Cheatham (Alt.)
Sun Microsystems, Inc. ....................... Scott Jameson
Gary S. Robinson (Alt.)
* Xerox Corporation ............................ Dwight McBain
Roy Pierce (Alt.)
3M Company ................................... Edie T. Morioka
Paul D. Jahnke (Alt.
Consumers Group
Boeing Company ............................... Catherine Howells
Andrea Vanosdoll (Alt.)
Eastman Kodak Company ........................ James Converse
Michael Nier (Alt.)
General Services Administration .............. Douglas Arai
Larry L. Jackson (Alt.)
Guide International Inc. ..................... Frank Kirshenbaum
Harold Kuneke (Alt.)
** Hughes Aircraft Company ...................... Harold Zebrack
National Communications Systems .............. Dennis Bodson
7
ANSI X3.215-1994
Northern Telecom Inc. ........................ Mel Woinsky
Subhash Patel (Alt.)
** Recognition Tech Users Association ........... Herbert P. Schantz
G. Edwin Hale (Alt.)
Share Inc. ................................... Gary Ainsworth
David Thewis (Alt.)
U. S. Department of Defense .................. William Rinehuls
C. J. Pasquariello (Alt.)
U. S. Department of Energy ................... Alton Cox
Lawrence A. Wasson (Alt.)
Wintergreen Information Services ............. John Wheeler
General Interest Group
American Nuclear Society ..................... Geraldine C. Main
Sally Hartzell (Alt.)
Assn. of the Institute for Certification
of Computer Professionals .................... Kenneth Zemrowski
Nat'l Institute of Standards and Technology .. Robert E. Rountree
Micharl Hogan (Alt.)
Neville & Associates ......................... Carlton Neville
------------------------------
* Abstain ** Non-Response
8
ANSI X3.215-1994
3J14 Membership
At the time it approved this draft of the proposed American National Standard, the
Technical Committee X3J14 on the Forth Programming Language had the following
members:
Elizabeth Rather, Chair
Mitch Bradley, acting Vice-Chair
Don Colburn, Secretary
John Rible, Technical Editor
Len Zettel, Vocabulary Representative
Greg Bailey, Technical Subcommittee Chair
Organization Represented Name of Representative
ATHENA Programming, Inc. ..................... Greg Bailey
Howe Fong (Alt.)
Bradley Forthware ............................ Mitch Bradley
Creative Solutions, Inc. ..................... Don Colburn
Ford Motor Company ........................... Leonard F. Zettel, Jr.
FORTH, Inc. .................................. Elizabeth Rather
Dennis Ruffer (Alt.)
Institute for Applied Forth Research ......... Lawrence Forsley
Horace Simmons (Alt.)
Johns Hopkins University, Applied Physics Lab. John Hayes
Mephistopheles Systems ....................... Dave Harralson
NASA/Goddard Space Flight Center ............. James Rash
Nomadic Software ............................. John K. Stevenson
Unisyn, Inc. ................................. Gary Betts
Stephen Egbert (Alt.)
Up and Running ............................... Martin Tracy
Vesta Technology ............................. Jack Woehr
Individual Members
Loring Craymer
John Rible
J. E. (Jet) Thomas
X3 Liasons
Clyde R. Camp
Kathleen McMillan
The following organizations and individuals have also participated in this project as
Technical Committee members, alternates, or observers. The Technical Committee recognizes
and respects their contributions:
Organizations
British Columbia Inst. of Tech. MCI Telecommunications Corp.
Computer Cowboys Micromotion
Computer Sciences Corp. MicroProcessor Engineering Ltd.
Computer Strategies, Inc. National Institute of Standards & Technology
9
ANSI X3.215-1994
Digalog Corp. NCR Medical Systems Group
Embedded Sys. Programming Mag. Performance Packages, Inc.
Forth Interest Group (FIG) Purdue University
H.B. Pascal & Co., Inc. Robert Berkey Services
Harris Semiconductor Shaw Laboratories
IBM Corporation Social Security Administration
IEEE Software Engineering
Kelly Enterprises Texas Instruments
Laboratory Microsystems, Inc. The Dickens Company
Maxtor Corp.
Individuals
David J. Angel Ray Duncan Charles Moore Dean Sanderson
Wil Baden Douglas Fishman Mike Nemeth George Shaw
Robert Berkey Tom Hand Harry Pascal Gerald Shifrin
Ron Braithwaite Gregory Ilg Stephen Pelc Robert Smith
Jack Brown Charles Keane Dean Perrine Tyler Sperry
Chris Colburn Guy M. Kelly David C. Petty Tom Zimmer
Ted Dickens Andrew Kobziar Bill Ragsdale
John Dorband Martin Lascelles James Ryland
10
ANSI X3.215-1994
AMERICAN NATIONAL STANDARD
ANSI X3.215-1994
American National Standard
for Information Systems --
Programming Languages ---
Forth
Forth
Forth
1.
Introduction
1.1
Purpose
The purpose of this Standard is to promote the portability of Forth programs for use on a
wide variety of computing systems, to facilitate the communication of programs,
programming techniques, and ideas among Forth programmers, and to serve as a
basis for the future evolution of the Forth language.
1.2
Scope
This Standard specifies an interface between a Forth System and a Forth Program by
defining the words provided by a Standard System.
1.2.1
Inclusions
This Standard specifies:
- the forms that a program written in the Forth language may take;
- the rules for interpreting the meaning of a program and its data.
1.2.2
Exclusions
This Standard does not specify:
- the mechanism by which programs are transformed for use on computing systems;
- the operations required for setup and control of the use of programs on computing
systems;
- the method of transcription of programs or their input or output data to or from a
storage medium;
- the program and Forth system behavior when the rules of this Standard fail to establish
an interpretation;
- the size or complexity of a program and its data that will exceed the capacity of any
specific computing system or the capability of a particular Forth system;
11
ANSI X3.215-1994
- the physical properties of input/output records, files, and units;
- the physical properties and implementation of storage.
1.3
Document organization
1.3.1
Word sets
This Standard groups Forth words and capabilities into word sets under a name indicating
some shared aspect, typically their common functional area. Each word set may have an
extension, containing words that offer additional functionality. These words are not
required in an implementation of the word set.
The "Core" word set, defined in sections 1 through 6, contains the required words and
capabilities of a Standard System. The other word sets, defined in sections 7 through 17,
are optional, making it possible to provide Standard Systems with tailored levels of
functionality.
1.3.1.1
Text sections
Within each word set, section 1 contains introductory and explanatory material and section
2 introduces terms and notation used throughout the Standard. There are no requirements
in these sections.
Sections 3 and 4 contain the usage and documentation requirements, respectively, for
Standard Systems and Programs, while section 5 specifies their labeling.
1.3.1.2
Glossary sections
Section 6 of each word set specifies the required behavior of the definitions in the word
set and the extensions word set.
1.3.2
Annexes
The annexes do not contain any required material.
Annex A provides some of the rationale behind the committee's decisions in creating this
Standard, as well as implementation examples. It has the same section numbering as the
body of the Standard to make it easy to relate each requirements section to its rationale
section.
Annex B is a short bibliography on Forth.
Annex C provides an introduction to Forth.
Annex D discusses the compatibility of ANS Forth with earlier Forths, emphasizing the
differences from Forth 83.
Annex E presents some techniques for writing portable programs in ANS Forth.
12
ANSI X3.215-1994
Annex F includes the words from all word sets in a single list, and serves as an index of
ANS Forth words.
1.4
Future directions
1.4.1
New technology
This Standard adopts certain words and practices that are increasingly found in common
practice. New words have also been adopted to ease creation of portable programs.
1.4.2
Obsolescent features
This Standard adopts certain words and practices that cause some previously used words to
become obsolescent. Although retained here because of their widespread use, their use in
new implementations or new programs is discouraged, because they may be withdrawn from
future revisions of the Standard.
This Standard designates the following words as obsolescent:
6.2.0060 #TIB 15.6.2.1580 FORGET 6.2.2240 SPAN
6.2.0970 CONVERT 6.2.2040 QUERY 6.2.2290 TIB
6.2.1390 EXPECT
13
ANSI X3.215-1994
2.
Terms, notation, and references
The phrase "See:" is used throughout this Standard to direct the reader to other sections
of the Standard that have a direct bearing on the current section.
In this Standard, "shall" states a requirement on a system or program; conversely, "shall
not" is a prohibition; "need not" means "is not required to"; "should" describes a
recommendation of the Standard; and "may", depending on context, means "is allowed to" or
"might happen".
Throughout the Standard, typefaces are used in the following manner:
- This proportional serif typeface is used for text, with italic used for symbols and the
first appearance of new terms;
- A bold proportional sans-serif typeface is used for headings;
- A bold monospaced serif typeface is used for Forth-language text.
.1 Definitions of terms
Terms defined in this section are used generally throughout this Standard. Additional
terms specific to individual word sets are defined in those word sets. Other terms are
defined at their first appearance, indicated by italic type. Terms not defined in this
Standard are to be construed according to the Dictionary for Information Systems, ANSI
X3.172-1990.
address unit: Depending on context, either 1) the units into which a Forth address space
is divided for the purposes of locating data objects such as characters and variables; 2)
the physical memory storage elements corresponding to those units; 3) the contents of such
a memory storage element; or 4) the units in which the length of a region of memory is
expressed.
aligned address: The address of a memory location at which a character, cell, cell pair,
or double-cell integer can be accessed.
ambiguous condition: A circumstance for which this Standard does not prescribe a specific
behavior for Forth systems and programs.
Ambiguous conditions include such things as the absence of a needed delimiter while
parsing, attempted access to a nonexistent file, or attempted use of a nonexistent word.
An ambiguous condition also exists when a Standard word is passed values that are improper
or out of range.
cell: The primary unit of information in the architecture of a Forth system.
cell pair: Two cells that are treated as a single unit.
character: Depending on context, either 1) a storage unit capable of holding a character;
or 2) a member of a character set.
14
ANSI X3.215-1994
character-aligned address: The address of a memory location at which a character can be
accessed.
character string: Data space that is associated with a sequence of consecutive character-
aligned addresses. Character strings usually contain text. Unless otherwise indicated,
the term "string" means "character string".
code space: The logical area of the dictionary in which word semantics are implemented.
compile: To transform source code into dictionary definitions.
compilation semantics: The behavior of a Forth definition when its name is encountered by
the text interpreter in compilation state.
counted string: A data structure consisting of one character containing a length followed
by zero or more contiguous data characters. Normally, counted strings contain text.
cross compiler: A system that compiles a program for later execution in an environment
that may be physically and logically different from the compiling environment. In a cross
compiler, the term "host" applies to the compiling environment, and the term "target"
applies to the run-time environment.
current definition: The definition whose compilation has been started but not yet ended.
data field: The data space associated with a word defined via CREATE.
data space: The logical area of the dictionary that can be accessed.
data-space pointer: The address of the next available data space location, i.e., the
value returned by HERE.
data stack: A stack that may be used for passing parameters between definitions. When
there is no possibility of confusion, the data stack is referred to as "the stack".
Contrast with return stack.
data type: An identifier for the set of values that a data object may have.
defining word: A Forth word that creates a new definition when executed.
definition: A Forth execution procedure compiled into the dictionary.
dictionary: An extensible structure that contains definitions and associated data space.
display: To send one or more characters to the user output device.
environmental dependencies: A program's implicit assumptions about a Forth system's
implementation options or underlying hardware. For example, a program that assumes a cell
size greater than 16 bits is said to have an environmental dependency.
execution semantics: The behavior of a Forth definition when it is executed.
15
ANSI X3.215-1994
execution token: A value that identifies the execution semantics of a definition.
find: To search the dictionary for a definition name matching a given string.
immediate word: A Forth word whose compilation semantics are to perform its execution
semantics.
implementation defined: Denotes system behaviors or features that must be provided and
documented by a system but whose further details are not prescribed by this Standard.
implementation dependent: Denotes system behaviors or features that must be provided by a
system but whose further details are not prescribed by this Standard.
input buffer: A region of memory containing the sequence of characters from the input
source that is currently accessible to a program.
input source: The device, file, block, or other entity that supplies characters to refill
the input buffer.
input source specification: A set of information describing a particular state of the
input source, input buffer, and parse area. This information is sufficient, when saved and
restored properly, to enable the nesting of parsing operations on the same or different
input sources.
interpretation semantics: The behavior of a Forth definition when its name is encountered
by the text interpreter in interpretation state.
keyboard event: A value received by the system denoting a user action at the user input
device. The term "keyboard" in this document does not exclude other types of user input
devices.
line: A sequence of characters followed by an actual or implied line terminator.
name space: The logical area of the dictionary in which definition names are stored.
number: In this Standard, "number" used without other qualification means "integer".
Similarly, "double number" means "double-cell integer".
parse: To select and exclude a character string from the parse area using a specified set
of delimiting characters, called delimiters.
parse area: The portion of the input buffer that has not yet been parsed, and is thus
available to the system for subsequent processing by the text interpreter and other
parsing operations.
pictured-numeric output: A number display format in which the number is converted using
Forth words that resemble a symbolic "picture" of the desired output.
program: A complete specification of execution to achieve a specific function
(application task) expressed in Forth source code form.
16
ANSI X3.215-1994
receive: To obtain characters from the user input device.
return stack: A stack that may be used for program execution nesting, do-loop execution,
temporary storage, and other purposes.
standard word: A named Forth procedure, formally specified in this Standard.
user input device: The input device currently selected as the source of received data,
typically a keyboard.
user output device: The output device currently selected as the destination of display
data.
variable: A named region of data space located and accessed by its memory address.
word: Depending on context, either 1) the name of a Forth definition; or 2) a parsed
sequence of non-space characters, which could be the name of a Forth definition.
word list: A list of associated Forth definition names that may be examined during a
dictionary search.
word set: A set of Forth definitions grouped together in this Standard under a name
indicating some shared aspect, typically their common functional area.
2.2
Notation
2.2.1
Numeric Notation
Unless otherwise stated, all references to numbers apply to signed single-cell integers.
The inclusive range of values is shown as {from...to}. The allowable range for the
contents of an address is shown in double braces, particularly for the contents of
variables, e.g., BASE {{2...36}}.
2.2.2
Stack notation
Stack parameters input to and output from a definition are described using the notation:
( stack-id before -- after )
where stack-id specifies which stack is being described, before represents the stack-
parameter data types before execution of the definition and after represents them after
execution. The symbols used in before and after are shown in table 3.1.
The control-flow-stack stack-id is "C:", the data-stack stack-id is "S:", and the return-
stack stack-id is "R:". When there is no confusion, the data-stack stack-id may be
omitted.
When there are alternate after representations, they are described by "after1 | after2".
The top of the stack is to the right. Only those stack items required for or provided by
17
ANSI X3.215-1994
execution of the definition are shown.
2.2.3
Parsed-text notation
If, in addition to using stack parameters, a definition parses text, that text is
specified by an abbreviation from table 2.1, shown surrounded by double-quotes and placed
between the before parameters and the "--" separator in the first stack described,
e.g.,
( S: before "parsed-text-abbreviation" -- after ).
Table 2.1 - Parsed text abbreviations
----------------------------------------------------------------------------------
Abbreviation Description
----------------------------------------------------------------------------------
<char> the delimiting character marking the end of the string being
parsed
<chars> zero or more consecutive occurrences of the character char
<space> a delimiting space character
<spaces> zero or more consecutive occurrences of the character space
<quote> a delimiting double quote
<paren> a delimiting right parenthesis
<eol> an implied delimiter marking the end of a line
ccc a parsed sequence of arbitrary characters, excluding the delimiter
character
name a token delimited by space, equivalent to ccc<space> or ccc<eol>
----------------------------------------------------------------------------------
2.2.4
Glossary notation
The glossary entries for each word set are listed in the standard ASCII collating
sequence. Each glossary entry specifies an ANS Forth word and consists of two parts: an
index line and the semantic description of the definition.
2.2.4.1
Glossary index line
The index line is a single-line entry containing, from left to right:
- Section number, the last four digits of which assign a unique sequential number to all
words included in this Standard;
- DEFINITION-NAME in upper-case, mono-spaced, bold-face letters;
- Natural-language pronunciation in quotes if it differs from English;
- Word-set designator from table 2.2. The designation for extensions word sets includes
"EXT".
Table 2.2 - Word set designators
18
ANSI X3.215-1994
Word set Designator
-------------------------------------
Core word set CORE
Block word set BLOCK
Double-Number word set DOUBLE
Exception word set EXCEPTION
Facility word set FACILITY
File-Access word set FILE
Floating-Point word set FLOATING
Locals word set LOCALS
Memory-Allocation word set MEMORY
Programming-Tools word set TOOLS
Search-Order word set SEARCH
String-Handling word set STRING
--------------------------------------
2.2.4.2
Glossary semantic description
The first paragraph of the semantic description contains a stack notation for each stack
affected by execution of the word. The remaining paragraphs contain a text description of
the semantics. See 3.4.3 Semantics.
2.3
References
The following national and international standards are referenced in this Standard:
ANSI X3.172-1990, Dictionary for information systems (2.1 Definition of terms);
ANSI X3.4-1974, American Standard Code for Information Interchange (ASCII) (3.1.2.1
Graphic characters);
ISO 646-1983, ISO 7-bit coded characterset for information interchange,
International Reference Version (IRV) (3.1.2.1 Graphic characters);
ANSI/IEEE 754-1985, Floating-point standard (12.2.1 Definition of terms).
19
ANSI X3.215-1994
3.
Usage requirements
A system shall provide all of the words defined in 6.1 Core Words. It may also provide
any words defined in the optional word sets and extensions word sets. No standard word
provided by a system shall alter the system state in a way that changes the effect of
execution of any other standard word except as provided in this Standard. A system may
contain non-standard extensions, provided that they are consistent with the
requirements of this Standard.
The implementation of a system may use words and techniques outside the scope of this
Standard.
A system need not provide all words in executable form. The implementation may provide
definitions, including definitions of words in the Core word set, in source form only. If
so, the mechanism for adding the definitions to the dictionary is implementation defined.
A program that requires a system to provide words or techniques not defined in this
Standard has an environmental dependency.
3.1
Data types
A data type identifies the set of permissible values for a data object. It is not a
property of a particular storage location or position on a stack. Moving a data object
shall not affect its type.
No data-type checking is required of a system. An ambiguous condition exists if an
incorrectly typed data object is encountered.
Table 3.1 summarizes the data types used throughout this Standard. Multiple instances of
the same type in the description of a definition are suffixed with a sequence digit
subscript to distinguish them.
3.1.1
Data-type relationships
Some of the data types are subtypes of other data types. A data type i is a subtype of
type j if and only if the members of i are a subset of the members of j. The following
list represents the subtype relationships using the phrase "i => j" to denote "i
is a subtype of j". The subtype relationship is transitive; if i => j and j => k then i
=> k:
+n => u => x;
+n => n => x;
char => +n;
a-addr => c-addr => addr => u;
flag => x;
20
ANSI X3.215-1994
xt => x;
+d => d => xd;
+d => ud => xd.
Any Forth definition that accepts an argument of type i shall also accept an argument that
is a subtype of i.
3.1.2
Character types
Characters shall be at least one address unit wide, contain at least eight bits, and have
a size less than or equal to cell size.
The characters provided by a system shall include the graphic characters {32..126}, which
represent graphic forms as shown in table 3.2.
3.1.2.1
Graphic characters
A graphic character is one that is normally displayed (e.g., A, #, &, 6). These values
and graphics, shown in table 3.2, are taken directly from ANS X3.4-1974 (ASCII) and ISO
646-1983, International Reference Version (IRV). The graphic forms of characters outside
the hex range {20..7E} are implementation-defined. Programs that use the graphic hex 24
(the currency sign) have an environmental dependency.
The graphic representation of characters is not restricted to particular type fonts or
styles. The graphics here are examples.
3.1.2.2
Control characters
All non-graphic characters included in the implementation-defined character set are
defined in this Standard as control characters. In particular, the characters {0..31},
which could be included in the implementation-defined character set, are control
characters.
Programs that require the ability to send or receive control characters have an
environmental dependency.
Table 3.1 - Data types
Symbol Data type Size on stack
-----------------------------------------------------------------
flag flag 1 cell
true true flag 1 cell
false false flag 1 cell
char character 1 cell
n signed number 1 cell
+n non-negative number 1 cell
u unsigned number 1 cell
21
ANSI X3.215-1994
n|u (1) number 1 cell
x unspecified cell 1 cell
xt execution token 1 cell
addr address 1 cell
a-addr aligned address 1 cell
c-addr character-aligned address 1 cell
d double-cell signed number 2 cells
+d double-cell non-negative number 2 cells
ud double-cell unsigned number 2 cells
d|ud (2) double-cell number 2 cells
xd unspecified cell pair 2 cells
colon-sys definition compilation implementation dependent
do-sys do-loop structures implementation dependent
case-sys CASE structures implementation dependent
of-sys OF structures implementation dependent
orig control-flow origins implementation dependent
dest control-flow destinations implementation dependent
loop-sys loop-control parameters implementation dependent
nest-sys definition calls implementation dependent
i*x, j*x, k*x (3) any data type 0 or more cells
----------------------------------------------------------------------------
(1) May be either a signed number or an unsigned number depending on context.
(2) May be either a double-cell signed number or a double-cell unsigned number depending
on context.
(3) May be an undetermined number of stack entries of unspecified type. For examples of
use, see 6.1.1370 EXECUTE, 6.1.2050 QUIT.
Table 3.2 - Standard graphic characters
Hex IRV ASCII Hex IRV ASCII Hex IRV ASCII Hex IRV ASCII Hex IRV ASCII Hex IRV ASCII
--- --- ----- --- --- ----- --- --- ----- --- --- ----- --- --- ----- --- --- -----
20 30 0 0 40 @ @ 50 P P 60 ` ` 70 p p
21 ! ! 31 1 1 41 A A 51 Q Q 61 a a 71 q q
22 " " 32 2 2 42 B B 52 R R 62 b b 72 r r
23 # # 33 3 3 43 C C 53 S S 63 c c 73 s s
24 - $ 34 4 4 44 D D 54 T T 64 d d 74 t t
25 % % 35 5 5 45 E E 55 U U 65 e e 75 u u
26 & & 36 6 6 46 F F 56 V V 66 f f 76 v v
27 ' ' 37 7 7 47 G G 57 W W 67 g g 77 w w
28 ( ( 38 8 8 48 H H 58 X X 68 h h 78 x x
29 ) ) 39 9 9 49 I I 59 Y Y 69 i i 79 y y
2A * * 3A : : 4A J J 5A Z Z 6A j j 7A z z
2B + + 3B ; ; 4B K K 5B [ [ 6B k k 7B { {
2C , , 3C < < 4C L L 5C \ \ 6C l l 7C | |
2D - - 3D = = 4D M M 5D ] ] 6D m m 7D } }
2E . . 3E > > 4E N N 5E ^ ^ 6E n n 7E ~ ~
22
ANSI X3.215-1994
2F / / 3F ? ? 4F O O 5F 6F o o
----------------------------------------------------------------------------------------
3.1.3
Single-cell types
The implementation-defined fixed size of a cell is specified in address units and the
corresponding number of bits. See E.2 Hardware peculiarities.
Cells shall be at least one address unit wide and contain at least sixteen bits. The size
of a cell shall be an integral multiple of the size of a character. Data-stack elements,
return-stack elements, addresses, execution tokens, flags, and integers are one cell wide.
3.1.3.1
Flags
Flags may have one of two logical states, true or false. Programs that use flags as
arithmetic operands have an environmental dependency.
A true flag returned by a standard word shall be a single-cell value with all bits set. A
false flag returned by a standard word shall be a single-cell value with all bits clear.
3.1.3.2
Integers
The implementation-defined range of signed integers shall include {-32767..+32767}.
The implementation-defined range of non-negative integers shall include {0..32767}.
The implementation-defined range of unsigned integers shall include {0..65535}.
3.1.3.3
Addresses
An address identifies a location in data space with a size of one address unit, which a
program may fetch from or store into except for the restrictions established in this
Standard. The size of an address unit is specified in bits. Each distinct address value
identifies exactly one such storage element. See 3.3.3 Data space.
The set of character-aligned addresses, addresses at which a character can be accessed, is
an implementation-defined subset of all addresses. Adding the size of a character to a
character-aligned address shall produce another character-aligned address.
The set of aligned addresses is an implementation-defined subset of character-aligned
addresses. Adding the size of a cell to an aligned address shall produce another aligned
address.
3.1.3.4
Counted strings
A counted string in memory is identified by the address (c-addr) of its length character.
The length character of a counted string shall contain a binary representation of the
number of data characters, between zero and the implementation-defined maximum length for
a counted string. The maximum length of a counted string shall be at least 255.
23
ANSI X3.215-1994
3.1.3.5
Execution tokens
Different definitions may have the same execution token if the definitions are equivalent.
3.1.4
Cell-pair types
A cell pair in memory consists of a sequence of two contiguous cells. The cell at the
lower address is the first cell, and its address is used to identify the cell pair.
Unless otherwise specified, a cell pair on a stack consists of the first cell immediately
above the second cell.
3.1.4.1
Double-cell integers
On the stack, the cell containing the most significant part of a double-cell integer shall
be above the cell containing the least significant part.
The implementation-defined range of double-cell signed integers shall include
{-2147483647..+2147483647}.
The implementation-defined range of double-cell non-negative integers shall include
{0..2147483647}.
The implementation-defined range of double-cell unsigned integers shall include
{0..4294967295}. Placing the single-cell integer zero on the stack above a single-cell
unsigned integer produces a double-cell unsigned integer with the same value. See 3.2.1.1
Internal number representation.
3.1.4.2
Character strings
A string is specified by a cell pair (c-addr u) representing its starting address and
length in characters.
3.1.5
System types
The system data types specify permitted word combinations during compilation and
execution.
3.1.5.1
System-compilation types
These data types denote zero or more items on the control-flow stack (see 3.2.3.2). The
possible presence of such items on the data stack means that any items already there shall
be unavailable to a program until the control-flow-stack items are consumed.
The implementation-dependent data generated upon beginning to compile a definition and
consumed at its close is represented by the symbol colon-sys throughout this Standard.
The implementation-dependent data generated upon beginning to compile a do-loop structure
such as DO ... LOOP and consumed at its close is represented by the symbol do-sys
throughout this Standard.
24
ANSI X3.215-1994
The implementation-dependent data generated upon beginning to compile a CASE ... ENDCASE
structure and consumed at its close is represented by the symbol case-sys throughout this
Standard.
The implementation-dependent data generated upon beginning to compile an OF ... ENDOF
structure and consumed at its close is represented by the symbol of-sys throughout this
Standard.
The implementation-dependent data generated and consumed by executing the other standard
control-flow words is represented by the symbols orig and dest throughout this Standard.
3.1.5.2
System-execution types
These data types denote zero or more items on the return stack. Their possible presence
means that any items already on the return stack shall be unavailable to a program until
the system-execution items are consumed.
The implementation-dependent data generated upon beginning to execute a definition and
consumed upon exiting it is represented by the symbol nest-sys throughout this Standard.
The implementation-dependent loop-control parameters used to control the execution of do-
loops are represented by the symbol loop-sys throughout this Standard. Loop-control
parameters shall be available inside the do-loop for words that use or change these
parameters, words such as I, J, LEAVE and UNLOOP.
3.2
The implementation environment
3.2.1
Numbers
3.2.1.1
Internal number representation
This Standard allows one's complement, two's complement, or sign-magnitude number
representations and arithmetic. Arithmetic zero is represented as the value of a single
cell with all bits clear.
The representation of a number as a compiled literal or in memory is implementation
dependent.
3.2.1.2
Digit conversion
Numbers shall be represented externally by using characters from the standard character
set.
Conversion between the internal and external forms of a digit shall behave as follows:
The value in BASE is the radix for number conversion. A digit has a value ranging from
zero to one less than the contents of BASE. The digit with the value zero corresponds to
the character "0". This representation of digits proceeds through the character set to
the decimal value nine corresponding to the character "9". For digits beginning with the
decimal value ten the graphic characters beginning with the character "A" are
25
ANSI X3.215-1994
used. This correspondence continues up to and including the digit with the decimal value
thirty-five which is represented by the character "Z". The conversion of digits outside
this range is implementation defined.
3.2.1.3
Free-field number display
Free-field number display uses the characters described in digit conversion, without
leading zeros, in a field the exact size of the converted string plus a trailing space.
If a number is zero, the least significant digit is not considered a leading zero. If the
number is negative, a leading minus sign is displayed.
Number display may use the pictured numeric output string buffer to hold partially
converted strings (see 3.3.3.6 Other transient regions).
3.2.2
Arithmetic
3.2.2.1
Integer division
Division produces a quotient q and a remainder r by dividing operand a by operand b.
Division operations return q, r, or both. The identity b*q + r = a shall hold for all a
and b.
When unsigned integers are divided and the remainder is not zero, q is the largest integer
less than the true quotient.
When signed integers are divided, the remainder is not zero, and a and b have the same
sign, q is the largest integer less than the true quotient. If only one operand is
negative, whether q is rounded toward negative infinity (floored division) or rounded
towards zero (symmetric division) is implementation defined.
Floored division is integer division in which the remainder carries the sign of the
divisor or is zero, and the quotient is rounded to its arithmetic floor. Symmetric
division is integer division in which the remainder carries the sign of the dividend or is
zero and the quotient is the mathematical quotient "rounded towards zero" or "truncated".
Examples of each are shown in tables 3.3 and 3.4.
In cases where the operands differ in sign and the rounding direction matters, a program
shall either include code generating the desired form of division, not relying on the
implementation-defined default result, or have an environmental dependency on the desired
rounding direction.
Table 3.3 - Floored Division Example
Dividend Divisor Remainder Quotient
-----------------------------------------
10 7 3 1
-10 7 4 -2
10 -7 -4 -2
-10 -7 -3 1
-----------------------------------------
26
ANSI X3.215-1994
Table 3.4 - Symmetric Division Example
Dividend Divisor Remainder Quotient
-----------------------------------------
10 7 3 1
-10 7 -3 -1
10 -7 3 -1
-10 -7 -3 1
-----------------------------------------
3.2.2.2