home *** CD-ROM | disk | FTP | other *** search
- ASMFZ80 -- FORTH Z80 Assembler page 1
-
- Copyright 1982 Michael M Rubenstein
-
- Description.
- ASMFZ80 is a Z80 assembler for use with Osborne or Software Works
- FORTH. Since ASMFZ80 is written in higher level FORTH, it should
- be possible to modify it to work with most FORTH implementations
- with no more than moderate difficulty.
-
- Using ASMFZ80.
- Most of the words added with ASMFZ80 are contained in the new
- vocabulary ASSEMBLER. Generally, it is not necessary to directly
- reference this vocabulary, since the defining word CODE
- automatically sets this as the context vocabulary.
-
- An assembler definition is started with the word CODE and
- terminated with the word NEXT,. NEXT, also resets the context
- vocabulary to the value it had before the definition was started.
-
- ASMFZ80 is installed high up in memory, above the usual
- dictionary. This allows one to create assembler definitions and
- then purge the assembler, reducing final program size.
-
- Example of use.
- The following in an assembler implementation of the word 2*
-
- code 2* hl pop,
- hl hl add,
- hl push,
- next,
-
- Description of assembler words.
- Most of the words added with the assembler are simply modified
- forms of standard Zilog Z80 assembler identifiers. Registers are
- indicated by the standard assembler mnemonics in normal order.
- The only exception is the I register, which is called II to avoid
- confusion with the standard FORTH word I. Note that this
- includes parenthesized registers. For example, to load the a
- register with the value addressed by the bc register, use the
- instruction
-
- a (bc) ld,
-
- Parenthesized addresses (e.g. (0100h)) are indicated by preceding
- the value with (). Note spaces must surround the ().
-
- Unparenthesized addresses and immediate values are simply written
- in the code. For example
-
- hl 20 ld,
-
- Addresses, rather than offsets, are used for relative jump
- instructions. The assembler computes the offset.
-
- èASMFZ80 -- FORTH Z80 Assembler page 2
-
-
- Conditions (i.e. z nz c nc pe po m p) are standard Zilog
- mnemonics. For example
-
-
- nz 5 call,
-
- As you have probably noticed, the instructions are simply
- standard Zilog mnemonics, followed by a comma.
-
- All instructions are implemented. Osborne users beware -- use of
- in or out instructions will likely crash the system.
-
- There is no label mechanism. Of course, you may use HERE to
- determine jump addresses, but this is unwieldly. Instead, four
- control structures are implemented:
-
- if, else, then,
- do, loop,
- begin, until,
- begin, while, repeat,
-
- The if, until, and while, controls operate like the standard
- FORTH versions, except that a condition is tested rather than a
- value. The words if, until, and while, must be preceded by a
- condition (e.g. z nz) and the code preceding the word must set
- the flags appropriately.
-
- The do, loop, structure generates a counted loop using the Z80
- djnz instruction. The count must be placed in the b register
- before the loop and must be in that register at the end. The
- count may be from 1 to 256 (0 is treated as 256). Note that
- Software Works FORTH requires that the bc register be unmodified
- by a function, so be sure to save it.
-
- Control structures may be nested to a depth of at least 10.
-
- The Z80 hardware stack is used as the data stack in Software
- Works FORTH, so values may be removed or added with pop, and
- push, instructions.
-
- WARNING: The bc register must be preserved in Software Works
- FORTH. Failure to do this will almost certainly crash
- the system.
-