Address Register Words
Chuck Moore's recent Forths have included words that work by fetching
and storing to an implied address, held in a variable called the address
register. This reduces stack manipulations required when accessing
several consecutive locations in memory, and leads to some very efficient
code, especially when used in loops.
Z88 CamelForth includes a loadable file which provides these
facilities; it is not as efficient as Chuck's implementation, since we don't
have any spare machine registers to hold the address register, but nevertheless
it can give good results (especially when compiled as
fast code.)
These words can be loaded with:
S" aregister.fth" INCLUDED
Address Register Manipulation
- A! ( addr -- )
- Sets the address register (A) to addr.
- A@ ( -- addr )
- Fetches the current address register (A).
Fetch/Store Words
- !A ( x -- )
- Store cell x at the address in A.
- @A ( -- x )
- Fetch cell at the address in A.
- C!A ( c -- )
- Store char c at the address in A.
- C@A ( -- c )
- Fetch char at the address in A.
Fetch/Store Words With Increment
- !A+ ( x -- )
- Store cell x at the address in A, and increment A to next cell address.
- @A+ ( -- x )
- Fetch cell at the address in A, and increment A to next cell address.
- C!A+ ( c -- )
- Store char c at the address in A, and increment A to next char address.
- C@A+ ( -- c )
- Fetch char at the address in A, and increment A to next char address.
More about CamelForth
Back to the Z88 home
page