Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Conklin E.K.Forth programmer's handbook.2000.pdf
Скачиваний:
321
Добавлен:
23.08.2013
Размер:
2.04 Mб
Скачать

Forth Programmer’s Handbook

1.3.2 Procedural Differences

1.3.2.1 Resident Assembler

The Forth assembler is normally resident at all times. This means a programmer can assemble code at any time, either from source on disk or by typing it directly from the terminal. Regardless of where the code comes from, the assembled version will be the same.

1.3.2.2 Immediately Executable Code

In conventional programming, assemblers leave their object code in a file, which must be integrated with code in files from high-level language compilers (if any) by a linker before the resultant program can be loaded into memory for testing. The resident Forth assembler assembles the code directly into memory in executable form, thus avoiding this cumbersome procedure.

1.3.2.3 Relationship to Other Routines

The Forth assembler is used to write short, named routines that function just like routines written in high-level Forth; that is, when the name of a routine is invoked, it will be executed. Like other Forth routines, code routines normally expect their arguments on the stack and leave their results there. Within a code definition, one may refer to defined constants (to get a value), variables (to get an address), or other defined data types. Code routines may be called from high-level definitions just as other Forth words are, but cannot themselves call high-level definitions.

1.3.2.4 Register Usage

A Forth system runs on a virtual machine. For optimum performance, some of its virtual registers are kept in actual hardware registers, which are permanently assigned. The product documentation for each Forth system documents the register assignments for that CPU. Some registers may be designated as scratch, meaning they can be used within a code routine without saving or restoring; those containing Forth pointers must be saved and restored, if needed. Forth system registers are given names which make refer-

Introduction 21

Соседние файлы в предмете Электротехника