% by Kevin Doyle
% For more details see F.NewWord
% Published by AMPLINEX May 1990
% For more details see F.NewWord
% Published by AMPLINEX May 1990
% Can be *EXECed into AMPLE
% Define new words as GVAR
"findword" [GVAR]
"wordname" [GVAR]
"nextword" [GVAR]
"wordshow" [GVAR]
"wordname" [GVAR]
"nextword" [GVAR]
"wordshow" [GVAR]
% Set up the above words with the
% values required
% values required
15 findword #! &2E findword 1 #- #B!
15 wordname #! &59 wordname 1 #- #B!
15 nextword #! &73 nextword 1 #- #B!
15 wordshow #! &B8 wordshow 1 #- #B!
15 wordname #! &59 wordname 1 #- #B!
15 nextword #! &73 nextword 1 #- #B!
15 wordshow #! &B8 wordshow 1 #- #B!
% Use new words in utility
"FREE" [
OFF % Set start value of 0
% for nextword
REP( % Begin main loop: this
% loop gets the token
% for each user word.
% This token will be
% the object searched
% for in each user word
% in the sub-loop below
6 nextword % Get address of first
% (or next) user word
)UNTIL( % Continue whilst more
% words
OFF % Set start value of 0
% for nextword
REP( % Begin main loop: this
% loop gets the token
% for each user word.
% This token will be
% the object searched
% for in each user word
% in the sub-loop below
6 nextword % Get address of first
% (or next) user word
)UNTIL( % Continue whilst more
% words
OFF #212 % Put OFF flag on stack
% and copy object word
% address to top. OFF
% flag is used to
% indicate the initial
% state - i.e. that no
% occurrence of the
% object token has been
% found
4 #+ % Add 4 to address to
% point to word name
% length byte
#11 % Duplicate address
% and copy object word
% address to top. OFF
% flag is used to
% indicate the initial
% state - i.e. that no
% occurrence of the
% object token has been
% found
4 #+ % Add 4 to address to
% point to word name
% length byte
#11 % Duplicate address
#B? % Read word length byte
15 AND % Remove top bit (&80)
% to give word length
#+ % Add word length to
% address to point to
% end of word name
1 #+ % Add 1 to address to
% point to word token
#? % Read word token bytes
% (i.e. token + &00)
#B12 % Reverse bytes to give
% &00 + token, the form
% of the token used in
% word definitions.
% This gives the object
% token to be searched
% for in the next loop
15 AND % Remove top bit (&80)
% to give word length
#+ % Add word length to
% address to point to
% end of word name
1 #+ % Add 1 to address to
% point to word token
#? % Read word token bytes
% (i.e. token + &00)
#B12 % Reverse bytes to give
% &00 + token, the form
% of the token used in
% word definitions.
% This gives the object
% token to be searched
% for in the next loop
OFF % Set start value of 0
% for nextword
REP( % Begin sub-loop
6 nextword % Get address of first
% (or next) user word
)UNTIL( % Continue whilst more
% words
#2121 % Duplicate top two
% items on the stack
% (i.e. the object word
% token and the target
% word address)
4 #+ % Add 4 to address to
% point to word name
% length byte
#11 % Duplicate address
% for nextword
REP( % Begin sub-loop
6 nextword % Get address of first
% (or next) user word
)UNTIL( % Continue whilst more
% words
#2121 % Duplicate top two
% items on the stack
% (i.e. the object word
% token and the target
% word address)
4 #+ % Add 4 to address to
% point to word name
% length byte
#11 % Duplicate address
#B? % Read word length byte
15 AND % Remove top bit (&80)
% to give word length
#+ % Add word length to
% address to point to
% end of word name
3 #+ % Add 3 to address to
% point to start of
% target word
% definition
findword % Find next occurrence
% of object token in
% target word. Returns
% address ON if found;
% OFF if not found
#11 % Duplicate find flag
15 AND % Remove top bit (&80)
% to give word length
#+ % Add word length to
% address to point to
% end of word name
3 #+ % Add 3 to address to
% point to start of
% target word
% definition
findword % Find next occurrence
% of object token in
% target word. Returns
% address ON if found;
% OFF if not found
#11 % Duplicate find flag
IF( % If found:
#12 #2 % Delete found address
% from stack
FRAME % Set frame pointer to
% top of stack
FRAME? % Read frame pointer
ON % Set fourth element
4 FVAR % on stack to ON to
#! % indicate that the
% object token has
% been found in the
% target word. This
% will replace the OFF
% flag put on the
% stack near the start
FRAME! % Write frame pointer
)IF % End of conditional
#12 #2 % Delete found address
% from stack
FRAME % Set frame pointer to
% top of stack
FRAME? % Read frame pointer
ON % Set fourth element
4 FVAR % on stack to ON to
#! % indicate that the
% object token has
% been found in the
% target word. This
% will replace the OFF
% flag put on the
% stack near the start
FRAME! % Write frame pointer
)IF % End of conditional
)UNTIL( % Repeat above until
% object found in
% target word
)REP % End of sub-loop
% object found in
% target word
)REP % End of sub-loop
#2 % Delete target address
% from stack
#2 % Delete object token
% from stack
NOT % Reverse flag - i.e.
% OFF (not found) => ON
% from stack
#2 % Delete object token
% from stack
NOT % Reverse flag - i.e.
% OFF (not found) => ON
IF( % If object token not
% found in any target
% word
#11 % Duplicate address of
% object word
4 #+ % Add 4 to address to
% point to word name
% length byte
wordname % Return string
% containing word name
wordshow % Pad out to fixed
% length and print
)IF % End of conditional
)REP % End of main loop
#2 % Delete last address
]
% found in any target
% word
#11 % Duplicate address of
% object word
4 #+ % Add 4 to address to
% point to word name
% length byte
wordname % Return string
% containing word name
wordshow % Pad out to fixed
% length and print
)IF % End of conditional
)REP % End of main loop
#2 % Delete last address
]
% Type FREE to use the utility
Published in AMPLINEX 017, May 1990