home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / beehive / cpmforth / mvpforth.lbr / MVPFORTH.DZC / MVPFORTH.DOC
Text File  |  1979-12-31  |  32KB  |  807 lines

  1.                      MVP-FORTH DOCUMENTATION         24 July 1991
  2.  
  3.  
  4. This  is  a  short  introduction to  MVP-FORTH  for  the  CP/M-80
  5. operating  system.   The  intention of these notes is to  present
  6. some   of   the   main  features   of   this   particular   forth
  7. implementation.
  8.  
  9.  
  10. 1. INTRODUCTION
  11.  
  12. MVP-FORTH  was introduced in the early 1980's and is the  product
  13. of  Glen B.  Haydon and Mountain View Press (USA).   It has  been
  14. produced for a number of machines including CP/M,  MS-DOS,  Apple
  15. and others.  MVP-FORTH has been placed into the public domain and
  16. this  has led to wide distribution of the program though  usually
  17. with little or no documentation.
  18.  
  19. The  following notes are based on this user's examination of MVP-
  20. FORTH.  While not suited to the total beginner, those having some
  21. familiarity  with  forth (in particular Fig-Forth on  which  MVP-
  22. FORTH  was  based) should find enough information to begin  using
  23. the system.
  24.  
  25. For additional information,  a book entitled 'All About FORTH' by
  26. Glen  B.  Haydon is available.   It is an annotated glossary  for
  27. MVP-FORTH.   It  may  be  obtained by mail order from  the  Forth
  28. Interest Group,  PO Box 8231 San Jose,  CA 95155 USA.   (Write to
  29. them for a mail-order form).   For those seeking an  introductory
  30. book about Forth,  'Starting FORTH' by Leo Brodie (Prentice Hall)
  31. is highly recommended.
  32.  
  33.  
  34. 2. THE MVP-FORTH SYSTEM
  35.  
  36. As mentioned earlier,  MVP-FORTH is a public domain software  and
  37. can be found on bulletin boards and in 'shareware' catalogs.   In
  38. this form, MVP-FORTH usually consists of the following files.
  39.  
  40. MVPFORTH.ASM   Assembler source for the MVP-FORTH kernel.
  41.  
  42. FORTH.COM      Executable  file consisting of the compiled kernel
  43.                and including the MVP extensions.
  44.  
  45. SCREENS.MVP    Later  versions of MVPFORTH appearing on  bulletin
  46.                boards  have  included  this  file.    It  is  the
  47.                contents   of   the  MVP-FORTH   'screens   disk',
  48.                compressed and compiled as a normal CP/M file.  It
  49.                contains  the source code for the assembler,  line
  50.                editor and the various extensions and utilities.
  51.  
  52.  
  53. 3. MVP-FORTH BASICS
  54.  
  55. To boot MVP-FORTH from the CP/M prompt, simply type
  56.  
  57.                     A> FORTH  <cr>
  58.  
  59. MVP-FORTH  issues  a  sign-on message and is ready  to  accept  a
  60. command
  61.  
  62.                     MVP-FORTH   VERSION 1.00.01
  63.  
  64. To  display  the  names of all forth commands  currently  in  the
  65. dictionary, type
  66.  
  67.                     VLIST
  68.  
  69. Note  that  the names of MVP-FORTH commands  are  case-sensitive.
  70. Executing a forth command requires that the user type the name of
  71. the command in the same way it was defined.   By convention,  all
  72. MVP-FORTH command names have been defined in uppercase.   Thus to
  73. access  these  commands,  the user must also type their names  in
  74. uppercase.
  75.  
  76. To return to CP/M is simply type, BYE.
  77.  
  78.  
  79. 4. FORTH-79 STANDARD WORDS
  80.  
  81. MVP-FORTH  for  CP/M  conforms  to  the  FORTH-79  STANDARD.   As
  82. required by the Standard, all the words from the Required Wordset
  83. are included.
  84.  
  85. Forth-79 Required Words
  86.  
  87. !       #       #>      #S      '       (       *       */
  88. */MOD   +       +!      +LOOP   ,       -       -TRAILING
  89. .       ."      /       /LOOP   /MOD    0<      0=      0>
  90. 1+      1-      2+      2-      79-STANDARD     :       ;
  91. <       <#      =       >       >IN     >R      ?       ?DUP
  92. @       ABORT   ABS     ALLOT   AND     BASE    BEGIN   BLK
  93. BLOCK   BUFFER  C!      C@      CMOVE   COMPILE CONSTANT
  94. CONTEXT CONVERT COUNT   CR      CREATE  CURRENT D+      D<
  95. DECIMAL DEFINITIONS     DEPTH   DNEGATE DO      DOES>   DROP
  96. DUP     ELSE    EMIT    EMPTY-BUFFERS   EXECUTE EXIT    EXPECT
  97. FILL    FIND    FORGET  FORTH   HERE    HEX     HOLD    I
  98. IF      IMMEDIATE       J       KEY     LEAVE   LIST    LITERAL
  99. LOAD    LOOP    MAX     MIN     MOD     MOVE    NEGATE  NOT
  100. NUMBER  OR      OVER    PAD     PICK    QUERY   QUIT    R>
  101. R@      REPEAT  ROLL    ROT     SAVE-BUFFERS    SCR     SIGN
  102. SPACE   SPACES  STATE   SWAP    THEN    TYPE    U*      U.
  103. U<      UNTIL   UPDATE  VARIABLE        VOCABULARY      WHILE
  104. WORD    XOR     [       [COMPILE]       ]
  105.  
  106.  
  107. 5. VECTORED WORDS
  108.  
  109. A feature of MVP-FORTH is that most of the input/output words are
  110. vectored.  Vectored words may have their behaviour altered by the
  111. user.
  112.  
  113. Vectored word       Vector              Default action word
  114.  
  115. -FIND               '-FIND              <-FIND>
  116. ?TERMINAL           '?TERMINAL          <?TERMINAL>
  117. ABORT               'ABORT              <ABORT>
  118. BLOCK               'BLOCK              <BLOCK>
  119. CR                  'CR                 <CR>
  120. EMIT                'EMIT               <EMIT>
  121. EXPECT              'EXPECT             <EXPECT>
  122. INTERPRET           'INTERPRET          <INTERPRET>
  123. KEY                 'KEY                <KEY>
  124. LOAD                'LOAD               <LOAD>
  125. NUMBER              'NUMBER             <NUMBER>
  126. PAGE                'PAGE               <PAGE>
  127. R/W                 'R/W                <R/W>
  128. T&SCALC             'T&SCALC            <T&SCALC>
  129. VOCABULARY          'VOCABULARY         <VOCABULARY79>
  130. WORD                'WORD               <WORD>
  131.  
  132. To  change the behaviour of a vectored word,  the user must first
  133. create a new forth definition having the new action.   The vector
  134. is then altered so that it points to this new definition.
  135.  
  136. As  an example,  assume that a new definition for EMIT  has  been
  137. written  called  <NEW-EMIT>.    To  have  EMIT  execute  the  new
  138. definition <NEW-EMIT>, we would write
  139.  
  140.      ' <NEW-EMIT>  CFA  'EMIT  !
  141.  
  142. Now,  when  any  forth function which contains the word  EMIT  is
  143. invoked, the action of <NEW-EMIT> will be executed.
  144.  
  145. Note that re-vectoring a forth word to perform a new function  is
  146. not  the  same  as redefining it (which only  alters  the  word's
  147. behaviour for subsequent definitions).   Once a vectored word has
  148. been  altered,  every forth function in the dictionary which uses
  149. that word will be affected.
  150.  
  151.  
  152. 6. BASIC SCREEN EDITING
  153.  
  154. MVP-FORTH provides the PP command, a basic tool for writing lines
  155. of text to a disk block.  It is the mechanism by which a user may
  156. initially  input  the source for an editor onto disk,  should  an
  157. editor not already be available.
  158.  
  159. To write a string of text to line 0 of screen 1, one would use -
  160.  
  161.         1 LIST                          (select screen 1)
  162.  
  163.         0 PP  THIS IS A LINE OF TEXT    (write text to line 0)
  164.  
  165.  
  166. 7. CUSTOMISING THE FORTH ENVIRONMENT
  167.  
  168. Two  commands are provided to allow the user to save a customised
  169. version of MVP-FORTH to disk.  These are FREEZE and CHANGE.  They
  170. are used as a prelude to the SAVE-FORTH command.
  171.  
  172. FREEZE  makes permanent any new word definitions that  have  been
  173. added  to the dictionary.   After a FREEZE any  word  definitions
  174. compiled  by the user may no longer be 'forgotten'.   FREEZE also
  175. makes  permanent  any  changes to the vectored words  or  to  the
  176. contents of the user variables SP0,  R0,  TIB, WIDTH and WARNING.
  177. FREEZE  is  automatically  performed whenever the BYE  or  CHANGE
  178. commands are issued.
  179.  
  180. The  CHANGE  command allows the top of memory and the  number  of
  181. disk  buffers to be changed.   The MVP-FORTH kernel has these set
  182. to  an address of 6000 hex and two buffers  respectively.   Those
  183. users having more available memory could increase these  allowing
  184. more space for forth applications etc.
  185.  
  186. As  an  example,  to increase the top of memory to A000  hex  and
  187. allow four disk block buffers, we would write -
  188.  
  189.                     HEX
  190.                     A000  ' LIMIT !
  191.                     4  ' #BUFF !
  192.                     DECIMAL
  193.                     CHANGE
  194.  
  195. After  compiling  a  new  application or  altering  the  system's
  196. default settings,  the user will probably want to save a  version
  197. of  MVP-FORTH  to disk which will boot up with these new  changes
  198. in place.  Two methods are available for doing this.
  199.  
  200. The first (and simplest) is the SAVE-FORTH  command.   SAVE-FORTH
  201. prompts the user for a filename and then writes the current forth
  202. image in memory to disk.
  203.  
  204. Note:   SAVE-FORTH  will  only  save to the A drive and  a  drive
  205. specifier should not be used in the filename.
  206.  
  207. The second method is the CP/M 2 SAVE command.  First exit to CP/M
  208. using  BYE.   MVP-FORTH  will  display  the number  of  pages  it
  209. currently occupies.  Then, at the CP/M prompt type -
  210.  
  211.                     SAVE n d:filename.typ
  212.  
  213. where  n  is number of pages to save and  d:filename.typ  is  the
  214. drive/filename  under which this new version of MVP-FORTH will be
  215. saved.  The only advantage of this method over the former is that
  216. drives other than A may be saved to.
  217.  
  218.  
  219. 8. CONFIGURING THE FORTH DISK
  220.  
  221. One  of  the major functions of CP/M's BDOS is that of disk  file
  222. management.   BDOS  handles the reading and writing of files  and
  223. maintains a file directory on every diskette.
  224.  
  225. Under  MVP-FORTH,  however,  CP/M's file management is  by-passed
  226. altogether.   Once  booted,  MVP-FORTH treats a disk simply as  a
  227. sequence of 1024 byte blocks.  Accessing a particular part of the
  228. disk is done using the forth word BLOCK.
  229.  
  230. WARNING:   This  disk management scheme is  totally  incompatible
  231. with CP/M files and disks.   After booting MVP-FORTH,  remove ALL
  232. CP/M  disks  from the drives immediately.   Thereafter  use  only
  233. blank,  formatted,  diskettes  as forth data disks.   Native mode
  234. forth does not recognise CP/M's system tracks, directory or files
  235. and it will happily overwrite them.
  236.  
  237. Many early forth systems (eg. Fig-Forth) used this method of disk
  238. access.    It  provided  uniformity  amongst  the  many  computer
  239. operating  systems and simplified the porting of Forth  to  other
  240. machines.
  241.  
  242. Before  accessing  a forth disk under MVP-FORTH,  the  user  must
  243. first  tell  the  system,  the number and capacity of  each  disk
  244. drive.  This is done using the CONFIGURE command.  When prompted,
  245. the  user may select a drive capacity which best  corresponds  to
  246. the  diskettes to be used (see the table  below).   The  selected
  247. capacity must be less than or equal to the actual capacity of the
  248. disk.
  249.  
  250. As an example,  if the user's disk was 40  tracks,  double-sided,
  251. and 36 sectors per side, the maximum capacity would be -
  252.  
  253.      tracks  *  sides  *  sectors  *  bytes/sec  =  capacity
  254.        40         2         36           128          360k
  255.  
  256. From  the  table,  the only possible density codes that could  be
  257. selected would be 0 or 1 as these have capacities of 100 and  250
  258. kbytes  respectively and  are less than or equal to the  diskette
  259. capacity  of 360 kbytes.   In practice,  density code 1 would  be
  260. chosen as this would make best use of the available disk space.
  261.  
  262. After using CONFIGURE, SAVE-FORTH may be used to make the changes
  263. permanent.  Refer to section 7 for details.
  264.  
  265. Finally,  the number of sectors per track SEC/TR refers to CP/M's
  266. 128  byte  'logical' sectors - not physical sectors.   Thus if  a
  267. diskette used nine 512 byte physical sectors,  the SEC/TR  figure
  268. would be  9 * (512/128) = 36.
  269.  
  270. Also,  the  name  of  each  density code  (ie.  8-SSSD)  is  only
  271. indicative of the physical diskette type.   If density code 1 was
  272. selected,  the diskette would not necessarily have to be '8 inch,
  273. single-sided, single-density'.
  274.  
  275. (As  provided,  the  file FORTH.COM is configured as  having  two
  276. drives  each with a density code of 0.   This will initially suit
  277. the majority of users.)
  278.  
  279. Density code    Sectors/block   Sectors/track   Blocks/drive
  280.  
  281.                    SEC/BLK          SEC/TR          B/DRV
  282.  
  283. 0 - 5-SSSD            8               20             100
  284. 1 - 8-SSSD            8               26             250
  285. 2 - 8-DSSD            8               26             500
  286. 3 - 8-SSDD            8               52             500
  287. 4 - 8-DSDD            8               52            1000
  288. 5 - 8-SSEXT           8               64             616
  289. 6 - 8-DSEXT           8               64            1232
  290.  
  291.                  Density Code and Disk Capacity
  292.  
  293.  
  294. 9. FORTH TO CP/M UTILITY
  295.  
  296. MVP-FORTH  has  a facility that will save a range of  blocks  (or
  297. 'screens') as a normal CP/M file.  This allows for the convenient
  298. transportation of forth source text between users.
  299.  
  300. SCREENS>FILE   reads  a  range  of  blocks  from  a  forth  disk,
  301. compresses  them  and  then saves them to a  CP/M  disk  using  a
  302. filename  specified  by  the user.   FILE>SCREENS  reverses  this
  303. process.
  304.  
  305. To  use,  simply  type  the appropriate  command  - the  user  is
  306. prompted for the screen numbers and the filename.
  307.  
  308.  
  309. 10. RE-CREATING THE MVP-FORTH 'SCREENS' DISK
  310.  
  311. SCREENS.MVP  is an example of a file created by the  SCREENS>FILE
  312. utility.   It is,  in fact,  the entire contents of the 'screens'
  313. disk provided when purchasing the MVP-FORTH system.   It contains
  314. the complete source text for the 8080 assembler,  line editor and
  315. the  various extentions and utilities compiled onto the MVP-FORTH
  316. kernel.
  317.  
  318. To  reconstruct the 'screens' disk from SCREENS.MVP,  perform the
  319. following steps.
  320.  
  321. a. Boot MVP-FORTH.
  322. b. Run CONFIGURE to suit the disk capacity of drive A (optional).
  323. c. Run CHANGE to set the limit of memory to A000 hex.
  324. d. Place a blank, formatted disk in drive A.
  325. e. Place the disk with the file SCREENS.MVP in drive B.
  326. f. Type FILE>SCREENS.
  327. g. When prompted, enter the source filename eg. B:SCREENS.MVP
  328. h. After the file has loaded, enter 0 as the starting screen
  329.    number.
  330.  
  331. When  the  process has finished,  the disk in drive A will  be  a
  332. forth disk containing the MVP-FORTH 'screens'.   The screens  may
  333. now be listed,  edited, or loaded.  Type  0 LIST  for an index of
  334. the utilities on the disk.
  335.  
  336.  
  337. 11. LINE EDITOR
  338.  
  339. The  source  code for a line editor is provided in  the  MVPFORTH
  340. utilities  screens.   With it,  the user can write or edit  forth
  341. source  text  which may then be compiled or  'LOAD'ed.   A  block
  342. containing  forth  source  text  is  usually  referred  to  as  a
  343. 'screen'.  By convention a screen is 64 columns by 16 lines.
  344.  
  345. These  days,  line editors are the exception rather than the rule
  346. and  most  users  quickly progress to some  form  of  full-screen
  347. editor where editing    is done by moving the cursor  around  the
  348. screen  and  making the appropriate  changes.   Such  full-screen
  349. editors,  however,  usually  require  customisation to  suit  the
  350. characteristics  of  the user's particular terminal  or  console.
  351. While  the speed of editing in a full-screen environment is to be
  352. preferred,  a  simple  line editor will function on  any  machine
  353. without modification.
  354.  
  355. The  line  editor is compatible with the Poly-FORTH  line  editor
  356. described  in the book 'Starting FORTH' by Leo Brodie  (Prentice-
  357. Hall,  first  edition).  Chapter  three of this book  contains  a
  358. tutorial on using the editor.
  359.  
  360. A summary of the line editor and related screen commands is given
  361. below.
  362.  
  363. General Block Commands
  364. ----------------------
  365. LIST ( n -- )       Lists  disk block n,  making it  the  current
  366.                     screen.
  367.  
  368. FLUSH               Forces any modifications that have been  made
  369.                     to a block to be written to disk.
  370.  
  371. EMPTY-BUFFERS       Marks  all block buffers as  empty.   Updated
  372.                     blocks currently in memory are not written to
  373.                     disk.
  374.  
  375. COPY  ( source dest -- )
  376.                     Copy  the contents of the source block to the
  377.                     destination block.
  378.  
  379. Editor Commands
  380. ---------------
  381. EDITOR              Invokes  the  editor  vocabulary  making  the
  382.                     editor  commands available.   Note - before a
  383.                     screen  may be edited it must first  be  made
  384.                     current.  This is done by 'LIST'ing it.
  385.  
  386. a. Editor Block Operators
  387.  
  388. L                   List the current screen.
  389.  
  390. N                   Increments the current screen number by one.
  391.  
  392. B                   Decrements the current screen number by one.
  393.  
  394. WIPE                Sets  the  contents of the current  block  to
  395.                     blanks.
  396.  
  397. b. Editor Line Operators
  398.  
  399. T  ( n -- )         TYPEs line n.
  400.  
  401. P xxx               Copies  the given string,  if any,  into  the
  402.                     insert buffer, then PUTs a copy of the insert
  403.                     buffer in the current line.
  404.  
  405. U xxx               Copies  the given string,  if any,  into  the
  406.                     inserts  buffer,  then  puts a  copy  of  the
  407.                     insert  buffer in the line UNDER the  current
  408.                     line.
  409.  
  410. M  ( block line -- )
  411.                     Copies  the  current  line  into  the  insert
  412.                     buffer, and MOVEs a copy of the insert buffer
  413.                     into the line under the specified line in the
  414.                     destination block.
  415.  
  416. X                   Copies  the  current  line  into  the  insert
  417.                     buffer and EXTRACTs the line from the block.
  418.  
  419. c. Editor String Operators
  420.  
  421. F xxx               Copies  the given string,  if any,  into  the
  422.                     find  buffer  then  FINDs the string  in  the
  423.                     current block.
  424.  
  425. S xxx  ( n -- )
  426.                     Copies  the given string,  if any,  into  the
  427.                     find  buffer,  then  SEARCHes  the  range  of
  428.                     blocks,  starting  from the current block and
  429.                     ending with n-1, for the string.
  430.  
  431. E                   To   be  used  after  F.    ERASEs  as   many
  432.                     characters  as  are  currently  in  the  find
  433.                     buffer, going backwards from the cursor.
  434.  
  435. D xxx               Copies  the given string,  if any,  into  the
  436.                     find buffer, finds the next occurrence of the
  437.                     string within the current line,  and  DELETEs
  438.                     it.
  439.  
  440. TILL xxx            Copies  the given string,  if any,  into  the
  441.                     find  buffer,  then  deletes  all  characters
  442.                     starting  from the current cursor position up
  443.                     TILL and including the string.
  444.  
  445. I xxx               Copies  the given string,  if any,  into  the
  446.                     insert  buffer,  then INSERTs the contents of
  447.                     the  insert buffer at the point  just  behind
  448.                     the cursor.
  449.  
  450. R xxx               Combines  the commands E and I to  REPLACE  a
  451.                     found  string  with  a given  string  or  the
  452.                     contents of the insert buffer.
  453.  
  454. ^                   Indicates   the  end  of  the  string  to  be
  455.                     placed  in  a  buffer.   Useful  for  placing
  456.                     multiple commands on a line.
  457.  
  458.  
  459. 12. 8080 ASSEMBLER
  460.  
  461. A  Forth  assembler  allows the user  to  write  forth  functions
  462. directly  in  the  assembly  code  of  his  particular  machine's
  463. microprocessor.   This is usually done when it is necessary for a
  464. routine to run at the highest possible speed.
  465.  
  466. An  8080  assembler is supplied with MVP-FORTH.   All Intel  8080
  467. instructions  are provided as well as facilities  for  structured
  468. programming  and  macros.   Like forth,  the  assembler  requires
  469. statements  to  be  entered  in  post-fix  format  (ie.  operands
  470. precede operators).
  471.  
  472. a. Machine Instructions
  473.  
  474. ACI  ADC  ADD  ADI  ANA  ANI  CALL CC   CM   CMA  CMC  CMP
  475. CNC  CP   CPE  CPI  CPO  CZ   DAA  DAD  DCR  DCX  DI   EI
  476. HLT  IN   INR  INX  JC   JM   JMP  JNC  JNZ  JP   JPE  JPO
  477. JZ   LDA  LDAX LHLD LXI  MOV  MVI  NOP  ORA  ORI  OUT  PCHL
  478. POP  PUSH RAL  RAR  RC   RET  RLC  RM   RNC  RNZ  RP   RPE
  479. RPO  RRC  RST  RZ   SBB  SBI  SHLD SPHL STA  STAX STC  SUB
  480. SUI  XCHG XRA  XTHL
  481.  
  482. b. Control Structures
  483.  
  484. IF .. THEN
  485. IF .. ELSE .. THEN
  486. BEGIN .. END             (Similar to forth's BEGIN UNTIL)
  487. BEGIN .. AGAIN
  488. BEGIN .. WHILE .. REPEAT
  489.  
  490. c. Conditional Tests
  491.  
  492. 0=        Equal to zero
  493. 0#        Not equal to zero
  494. CS        Carry set
  495. CNS       Carry not set
  496. PO        Parity odd
  497. PE        Parity even
  498. 0<        Less than zero (ie. negative)
  499. 0>=       Greater than or equal to zero (ie. positive)
  500.  
  501. d. Forth Interface
  502.  
  503. ASSEMBLER           Select the assembler vocabulary.
  504.  
  505. CODE <name>         Begins a code definition.
  506.  
  507. ;CODE               Begins  a  code  definition of  the  run-time
  508.                     portion of a forth defining word.
  509.  
  510. END-CODE            Terminates a code definition.
  511.  
  512. Note - All forth code routines must preserve the contents of  the
  513. BC  register and return to forth's address interpreter via a jump
  514. to  NEXT,  HPUSH  or DPUSH.   The organisation of  NEXT,  forth's
  515. address interpreter, is shown below.
  516.  
  517.     DPUSH:  PUSH  D      ; Push DE onto parameter stack then,
  518.     HPUSH:  PUSH  H      ; Push HL onto parameter stack then,
  519.     NEXT:   LDAX  B      ; Interpret the next forth word.
  520.             ....
  521.  
  522. e. Example
  523.  
  524. The  following sample code routine is a machine language  version
  525. of the forth word ?DUP.   ?DUP duplicates the value on top of the
  526. stack  only  if it is non zero.   In conventional  8080  assembly
  527. language, this could be written as follows -
  528.  
  529.           POP   H        ; Get a copy of the value on top of the
  530.           PUSH  H        ;  parameter stack into the HL register.
  531.           MOV   A,L      ; Move low byte to the accumulator
  532.           ORA   H        ;  and 'OR' it with the high byte.
  533.           JZ    ISZERO   ; Jump if zero flag is set, ie. HL=0
  534.           PUSH  H        ;  else push another copy onto stack.
  535.  ISZERO:  JMP   NEXT     ; Return to forth.
  536.  
  537. Using  the  forth  8080 assembler,  the  same  routine  would  be
  538. written -
  539.  
  540.     CODE  ?DUP           ( begin the code definition )
  541.           H     POP
  542.           H     PUSH
  543.           L A   MOV
  544.           H     ORA
  545.           0= IF          ( compiles 'jump if zero' )
  546.           H     PUSH
  547.     THEN  NEXT  JMP
  548.           END-CODE       ( end the definition )
  549.  
  550.  
  551. 13. GLOSSARY OF MISCELLANEOUS FUNCTIONS
  552.  
  553. Arithmetic Operators
  554. --------------------
  555. M*  ( n1 n2 -- d )       Multiply  n1  by  n2  leaving  a  double
  556.                          number result.
  557.  
  558. M*/  ( d1 n1 n2 -- d2)   Multiply    d1   by   n1   leaving    an
  559.                          intermediate  triple result then  divide
  560.                          by n2 leaving the double result.
  561.  
  562. M/  ( d n1 -- n2 n3 )    Leaves   the  signed  remainder  n2  and
  563.                          signed quotient n3 from a double  number
  564.                          dividend   d   and  divisor   n1.    The
  565.                          remainder   takes  its  sign  from   the
  566.                          dividend.
  567.  
  568. M/MOD  ( ud1 u1 -- u2 ud2 )
  569.                          An  unsigned operator which  leaves  the
  570.                          double quotient ud2 and single remainder
  571.                          u2 from a double dividend ud1 and single
  572.                          divisor.
  573.  
  574. M+  ( d1 n -- d2 )       Leaves the double number sum of a double
  575.                          d1 and single n numbers.
  576.  
  577. Screen Editing Commands
  578. -----------------------
  579. CLEAR  ( n -- )          Clear screen n by filling it with blanks
  580.                          and writes it to disk.
  581.  
  582. PP   (  n <text> -- )    Writes  <text> to line n of the  current
  583.                          screen.  The screen must have been prev-
  584.                          iously selected with LIST.
  585.  
  586. System
  587. ------
  588. BYE                      Exit to CP/M.
  589.  
  590. COLD                     Return  forth to the startup  condition.
  591.                          Any  newly defined words or changes  are
  592.                          discarded.
  593.  
  594. FREEZE                   Makes permanent any new word definitions
  595.                          added to the dictionary,  changes to the
  596.                          vectored words and the current  contents
  597.                          of SP0, R0, TIB, WIDTH and WARNING.
  598.  
  599. CHANGE                   Performs FREEZE and reboots the  system.
  600.                          Top  of  memory and number disk  buffers
  601.                          are set according to the values of LIMIT
  602.                          and #BUFF.
  603.  
  604. SAVE-FORTH               Save the present forth image to the disk
  605.                          in drive A as a CP/M file.
  606.  
  607. Disk Functions
  608. --------------
  609. CONFIGURE                Allows  the  user to specify the  number
  610.                          and capacity of each 'native' forth disk
  611.                          in the system.
  612.  
  613. ?CONFIGURE               Display the current disk configuration.
  614.  
  615. DR0 DR1 DR2 DR3          Select the specified disk drive.
  616.  
  617. DISK-ERROR ( -- adr )    Variable  which contains the BIOS  error
  618.                          code   for  the  last  disk   read/write
  619.                          operation.
  620.  
  621. Console Functions
  622. -----------------
  623. ?TERMINAL  ( -- f )      Leaves  a flag on the  stack  indicating
  624.                          whether a console key has been pressed.
  625.  
  626. Ctrl-P                   Ctrl-P keystrokes are intercepted by the
  627.                          forth word KEY.   Ctrl-P toggles EPRINT,
  628.                          a  variable  which controls the echo  of
  629.                          screen output to the printer.
  630.  
  631. PAGE                     Clears the screen and sets the cursor to
  632.                          the   top   left.    This  function   is
  633.                          currently vectored to perform a CR.
  634.  
  635. OUT  ( -- adr )          A  variable which contains the number of
  636.                          characters  EMITed  since the  last  CR.
  637.                          (* Does not function correctly due to an
  638.                          error in CR).
  639.  
  640. CP/M and 8080 Functions
  641. -----------------------
  642. SYSCALL  ( fn parm -- result )
  643.                          Call  BDOS function number fn.  Parm  is
  644.                          the  parameter  to be placed in  the  DE
  645.                          register  before the call and the result
  646.                          is returned in the A register.
  647.  
  648. P@  ( port -- byte )     Performs the 8080 IN instruction.
  649.  
  650. P!  ( byte port -- )     Performs the 8080 OUT instruction.
  651.  
  652. GO  ( adr -- )           Jump to address, and execute machine code.
  653.  
  654. Useful Constants
  655. ----------------
  656. LIMIT  ( -- adr )   Address of the highest system memory + 1.
  657.  
  658. BL     ( -- 32 )    Ascii value for space ie. 'blank'.
  659.  
  660. C/L    ( -- 64 )    Number of columns per line on screen.
  661.  
  662. #BUFF  ( -- n )     Number of disk buffers.
  663.  
  664. Useful Variables
  665. ----------------
  666. TIB    ( -- adr )  Contains  the  address of the  terminal  input
  667.                    buffer.
  668.  
  669. OUT    ( -- adr )  Contains the current screen column position.
  670.  
  671. WARNING ( -- adr ) Contains  a flag which controls the display of
  672.                    error messages.
  673.  
  674. WIDTH  ( -- adr )  Contains  the  maximum  number  of  characters
  675.                    saved  in  the compilation of  a  definition's
  676.                    name.
  677.  
  678. String operations
  679. -----------------
  680. <CMOVE  ( adr1 adr2 u -- )
  681.                     As  for  CMOVE  but  begins  move  with  last
  682.                     address first.
  683.  
  684. BMOVE  ( adr1 adr2 u -- )
  685.                     Move  u bytes from address 1 to address 2  in
  686.                     either direction without overlap.
  687.  
  688. ERASE  ( adr u -- ) Fill u bytes beginning at address with zeroes
  689.  
  690. -TEXT  ( adr1 u adr2 -- f )
  691.                     Compares  two strings that start at adr1  and
  692.                     adr2,  each  of length u.   Returns false  if
  693.                     they  match,  true  if no match (positive  if
  694.                     string 1 > 2, negative if 1 < 2).
  695.  
  696. Interpretation
  697. --------------
  698. TEXT  ( c -- )      Similar to WORD but leaves the string at PAD.
  699.  
  700. ( xxx)              Causes  the  string xxx to be ignored by  the
  701.                     text  interpreter  until the delimiter  )  is
  702.                     found.
  703.  
  704. \                   Cause  the  text interpreter to skip  to  the
  705.                     next  line,  ignoring  the remainder  of  the
  706.                     current line.
  707.  
  708. Loading
  709. -------
  710. LOAD  ( n -- )      Loads a disk block (compiles or executes).
  711.  
  712. THRU  ( n1 n2 -- )  Load a range of blocks from n1 to n2.
  713.  
  714. -->                 Immediately terminates loading of the current
  715.                     block and begins loading the next  sequential
  716.                     disk block.
  717.  
  718. Screens
  719. -------
  720. INDEX  ( n1 n2 -- ) Lists the first line only of each disk  block
  721.                     in the range n1 to n2.   By  convention,  the
  722.                     first  line  of  a screen is  reserved  as  a
  723.                     comment  line indicating the contents of  the
  724.                     block.
  725.  
  726. TRIAD  ( n -- )     Display  the  three  screens  which  includes
  727.                     screen  n  beginning  with  a  screen  evenly
  728.                     divisible by three.   Output is suitable  for
  729.                     source text records.
  730.  
  731. Dictionary
  732. ----------
  733. VLIST               List  the  names  of the definitions  in  the
  734.                     context vocabulary.
  735.  
  736. EMPTY               Discard  all user definitions (since the last
  737.                     COLD or FREEZE).
  738.  
  739. Utilities
  740. ---------
  741. DUMP  ( adr u -- )  Display  the contents of memory beginning  at
  742.                     address a1 for u bytes.
  743.  
  744. .S  ( ? -- ? )      Non-destructively    display    all    values
  745.                     currently on the parameter stack.
  746.  
  747. OCTAL               Set the current number base to 8.
  748.  
  749. U.R  ( u n -- )     Print an unsigned number,  right-aligned in a
  750.                     field n characters wide.
  751.  
  752. D.  ( d -- )        Print  a signed double number followed  by  a
  753.                     space.
  754.  
  755. D.R  ( d n -- )     Print  a signed double number,  right-aligned
  756.                     in a field n characters wide.
  757.  
  758. [']                 Compile  the parameter field address  of  the
  759.                     next word in the input stream as a literal.
  760.  
  761.  
  762. 14. 'STARTING FORTH' COMPATIBILITY WORDS
  763.  
  764. H                   DP
  765. 'S                  SP@
  766. >BINARY             CONVERT
  767. 2DROP               DDROP
  768. 2DUP                DDUP
  769. 2OVER               DOVER
  770. 2SWAP               DSWAP
  771. 2CONSTANT           DCONSTANT
  772. 2VARIABLE           DVARIABLE
  773. 2@                  D@
  774. 2!                  D!
  775.  
  776.  
  777. 15. MVP-FORTH MEMORY MAP
  778.  
  779. The following addresses are applicable to the assembled MVP-FORTH
  780. kernel  before  any  memory  size changes  or  additions  to  the
  781. disctionary are made.
  782.  
  783.  
  784.      LIMIT     +-----------------------+ 6000h
  785.                |      disk buffers     |
  786.                |                       |
  787.      FIRST     |-----------------------| 57F8h
  788.                |     user variables    |
  789.      R0        |-----------------------| 57A6h
  790.                |      return stack     |
  791.                |                       |
  792.                | terminal input buffer |
  793.      SP0       |-----------------------| 5706h
  794.                |    parameter stack    |
  795.                |                       |
  796.                |                       |
  797.                |      free memory      |
  798.      PAD       |-----------------------| 2508h
  799.                |                       |
  800.      HERE      |-----------------------| 24C4h
  801.                |                       |
  802.                |    forth dictionary   |
  803.                |     moving upwards    |
  804.                |                       |
  805.                +-----------------------+ 0100h
  806.  
  807.