Forth Programmer's Handbook

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Author(s): Edward K. Conklin, Elizabeth D. Rather
Edition: 3
Publisher: BookSurge Publishing
Year: 2010

Language: English
Pages: 274

Contents
Preface to the Third Edition
Welcome!
About the Forth Programming Language
About This Book
How to Use This Book
Typographic Conventions
Reference Materials
How to Proceed
1. Introduction
1.1 Forth Language Features
1.1.1 Definitions of Terms
1.1.2 Dictionary
1.1.3 Data Stack
1.1.4 Return Stack
1.1.5 Text Interpreter
1.1.6 Numeric Input
1.1.7 Two-stack Virtual Machine
1.2 Forth Operating System Features
1.2.1 Disk I/O
1.2.2 Multitasking
1.3 The Forth Assembler
1.3.1 Notational Differences
1.3.2 Procedural Differences
1.4 Documentation and Programmer Aids
1.4.1 Comments
1.4.2 Locating Command Source
1.4.3 Cross-references
1.4.4 Decompiler and Disassembler
1.5 Interactive Programming—An Example
2. Forth Fundamentals
2.1 Stack Operations
2.1.1 Stack Notation
2.1.2 Data Stack Manipulation
2.1.3 Return Stack Manipulation
2.1.4 Programmer Conveniences
2.2 Arithmetic and Logical Operations
2.2.1 Arithmetic and Shift Operators
2.2.2 Logical Operations
2.3 Memory and Data Storage
2.3.1 Defining Words
2.3.2 Single Data Objects
2.3.3 Arrays and Tables
2.3.4 Memory Stack Operations
2.3.5 Data Object and Memory Access Examples
3. String Handling
3.1 General String Topics
3.1.1 Single Characters
3.1.2 Scratch Storage for Strings
3.1.3 Internal String Format
3.2 Strings in Definitions
3.3 Strings in Data Structures
3.4 String Management Operations
3.5 Comparing Character Strings
3.6 Number Conversions
3.6.1 Input Number Conversion
3.6.2 Numeric Output
3.6.3 Processing Special Characters
4. Structured Programming
4.1 Controlling Program Flow
4.2 Comparison and Testing Operations
4.3 Conditionals
4.4 Indefinite Loops
4.4.1 Infinite loops
4.4.2 Post-testing loops
4.4.3 Pre-testing loops
4.5 Counting (Finite) Loops
4.6 Finite vs. Indefinite Loops
4.7 Case Statement
4.8 Nesting Structures
4.9 Nesting and Un-nesting Structures and Definitions
5. System Functions
5.1 Vectored Execution
5.1.1 Execution Tokens
5.1.2 Single Function Pointers
5.1.3 Execution Vector Tables
5.1.4 Vectored System Routines
5.2 System Environment
5.3 Exception Handling
5.4 Serial I/O
5.4.1 Terminal Input
5.4.2 Terminal Output
5.4.3 Support of Special Terminal Features
5.5 File-Based Disk Access
5.5.1 Overview
5.5.2 Global File Operations
5.5.3 File Reading and Writing
5.5.4 File Support Words
5.6 Time and Timing Functions
5.7 Dynamic Memory Management
5.8 Floating Point
5.8.1 Floating-Point System Guidelines
5.8.2 Input Number Conversion
5.8.3 Output Formats
5.8.4 Floating-Point Constants, Variables, and Literals
5.8.5 Memory Access
5.8.6 Floating-Point Stack Operators
5.8.7 Floating-Point Arithmetic
5.8.8 Floating-Point Conditionals
5.8.9 Logarithmic and Trigonometric Functions
5.8.10 Address Management
5.8.11 Custom I/O
6. The Forth Interpreter and Compiler
6.1 The Text Interpreter
6.1.1 Input Sources
6.1.2 Input Source Management
6.1.3 Parsing Text in the Input Stream
6.1.4 Dictionary Searches
6.1.5 Text Interpreter Conditionals
6.2 Defining Words
6.2.1 Creating a Dictionary Entry
6.2.2 Colon Definitions
6.2.3 Code Definitions
6.2.4 Custom Defining Words
6.3 Compiling Words and Literals
6.3.1 The Forth Compiler
6.3.2 Literals and Constants
6.3.3 Compiling Execution Tokens
6.3.4 Compiling Strings
6.4 Compiler Directives
6.4.1 Making Compiler Directives
6.4.2 The Control-flow Stack and Custom Compiling Structures
6.5 Overlays
6.6 Word Lists
6.6.1 Basic Principles
6.6.2 Managing Word Lists
6.6.3 Sealed Word Lists
7. Forth Cross compilers
7.1 Issues in Cross Development
7.2 Host and Target Roles and Functions
7.3 Managing Scopes
7.4 Data Space Management
7.4.1 Vectored Words
7.4.2 Data Types
7.4.3 Effects of Scoping on Data Object Defining Words
7.5 Interactive Programming
7.6 I/O Drivers for Embedded Systems
8. Programming Style and Editing Standards
8.1 FORTH, Inc. Editing Standards
8.1.1 Stack Effects
8.1.2 General Comments
8.1.3 Spacing Within Files
8.2 Open Firmware Coding Style
8.2.1 Typographic Conventions
8.2.2 Use of Spaces
8.2.3 Conditional Structures
8.2.4 Finite Loop Structures
8.2.5 Indefinite Pre-testing Loop Structures
8.2.6 Indefinite Post-testing Loop Structures
8.2.7 Block Comments
8.2.8 Stack Comments
8.2.9 Return Stack Comments
8.2.10 Numbers
8.3 Wong’s Rules for Readable Forth
8.3.1 Example: Magic Numbers
8.3.2 Example: Factoring
8.3.3 Example: Simplicity
8.3.4 Example: Testing Assumptions
8.3.5 Example: IF Avoidance
8.3.6 Example: Stack Music
8.3.7 Summary
8.4 Naming Conventions
Appendix A: Bibliography
Appendix B: Glossary & Notation
B.1 Glossary
B.2 Data Types in Stack Notation
B.3 Flags and IOR Codes
B.4 Forth Glossary Notation
Appendix C: Blocks for Disk Storage
C.1 Overview
C.1.1 Block-Management Fundamentals
C.2 Loading Forth Source Blocks
C.2.1 The LOAD Operation
C.2.2 Named Program Blocks
C.3 Block-based Programmer Aids and Utilities
C.4 Style Guidelines for Block-based Source
C.4.1 Stack Effects
C.4.2 General Comments
C.4.3 Spacing Within Source
Appendix D: Index to Forth Words
General Index