: SFILT
SLEN \sinfo1 sinfo2 — sinfo1 sinfo2 stringlength2 IF \compare length of source string to zero CGET \ not zero: — sinfo1 sinfo2’ char XTRANS \ apply transformation: — sinfo1 sinfo2’ char’ \stack has sinfo1, sinfo2, trsanslatedchar >R \save chr SSWAP \sinfo2 sinfo1 R> \get chr C+ \append chr to sinfo1 SSWAP \sinfo1 sinfo2 \next instruction is assembler...if we use high level call linkage \there is danger of return stack overflow...this way is stable JMPS SFILT \recursively call til entire string scanned ELSE SDROP \ string exhausted...discard sinfo THEN ; \complete
: DEST-INIT \ — sinfo1 "You know that " ;
: SOURCE \ — sinfo2
"Some different alpha characters are commonly used in Germany." ;
: SETUP \ — sinfo DEST-INIT DEST SCOPY ; \copy string to string buffer
\main procedure : MAIN SETUP \initialize destination area SOURCE SFILT \translate and append source SPRINT ; \output result to console
\ Define MAIN as startup routine: END MAIN
[LISTING FIVE]
MODULE string handling. LAYER main layer. SECTION string transformers. .... ENDSEC string transformers.
SECTION char transformers. .... ENDSEC char transformers. ENDLAY main layer. ENDMOD string handling.
[LISTING SIX]
CONST auxout fun = 4. # DOS function code ’serial output’ #
# Synopsis: auxout +c # # Function: Sends character c to device AUX # # Note: AUX defaults to COM1. This assignment may be # # changed by the MODE command of DOS #
ACTION auxout +>c : loadax +auxout fun, loaddl +c, int21.
# The syntax of the following terminal productions depends # # on the code generator used. #
ACTION loadax +>value = "MOV AX," value. ACTION loaddl +>value = "MOV DL," value. ACTION int21 = "INT 21H".
[LISTING SEVEN]
# Synopsis: sfilt +source string +target string # # Function: Appends source to target string by applying # # transformation ’xtrans’ to every character of # # source string # VAR first char . # temporary variable to hold one char #
ACTION sfilt +>source +>target> : nullstring +source; # finish when source=NULL # (but first +source +first char,# else drop first char # xtrans +first char, # translate it # append char +first char+target,# append to target # sfilt +source +target). # repeat the process #
# Refinement. Note that the following base words have to be # # expanded by appropriate assembler statements. # TEST nullstring +>string = ........ # test if string=NULL # ACTION but first +>string> +char> = ......... # move head of string to char # ACTION xtrans +>a char> = ......... # translate ’a char’ # ACTION append char +>char +>str>=.. # append char to str #
This document was generated on January 31, 2023 using texi2html 5.0.