home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / soundpot / f / mvpforth.lbr / ASMFZ80.DZC / ASMFZ80.DOC
Encoding:
Text File  |  1993-10-26  |  3.9 KB  |  102 lines

  1. ASMFZ80 -- FORTH Z80 Assembler                     page 1
  2.  
  3. Copyright 1982  Michael M Rubenstein
  4.  
  5. Description.
  6. ASMFZ80 is a Z80 assembler for use with Osborne or Software Works 
  7. FORTH.  Since ASMFZ80 is written in higher level FORTH, it should 
  8. be  possible to modify it to work with most FORTH implementations 
  9. with no more than moderate difficulty.
  10.  
  11. Using ASMFZ80.
  12. Most  of  the words added with ASMFZ80 are contained in  the  new 
  13. vocabulary ASSEMBLER.  Generally, it is not necessary to directly 
  14. reference   this  vocabulary,   since  the  defining  word   CODE 
  15. automatically sets this as the context vocabulary.
  16.  
  17. An  assembler  definition  is  started with  the  word  CODE  and 
  18. terminated with the word NEXT,.   NEXT,  also resets the  context 
  19. vocabulary to the value it had before the definition was started.
  20.  
  21. ASMFZ80  is  installed  high  up  in  memory,   above  the  usual 
  22. dictionary.   This allows one to create assembler definitions and 
  23. then purge the assembler, reducing final program size.
  24.  
  25. Example of use.
  26. The following in an assembler implementation of the word 2*
  27.  
  28.      code 2* hl pop,
  29.              hl hl add,
  30.              hl push,
  31.      next,
  32.  
  33. Description of assembler words.
  34. Most  of  the words added with the assembler are simply  modified 
  35. forms of standard Zilog Z80 assembler identifiers.  Registers are 
  36. indicated  by the standard assembler mnemonics in  normal  order.  
  37. The only exception is the I register, which is called II to avoid 
  38. confusion  with  the  standard  FORTH word  I.   Note  that  this 
  39. includes  parenthesized registers.   For example,  to load the  a 
  40. register  with the value addressed by the bc  register,  use  the 
  41. instruction
  42.  
  43.      a (bc) ld,
  44.  
  45. Parenthesized addresses (e.g. (0100h)) are indicated by preceding 
  46. the value with ().  Note spaces must surround the ().
  47.  
  48. Unparenthesized addresses and immediate values are simply written 
  49. in the code.  For example
  50.  
  51.      hl 20 ld,
  52.  
  53. Addresses,  rather  than  offsets,  are  used for  relative  jump 
  54. instructions.  The assembler computes the offset.
  55.  
  56. èASMFZ80 -- FORTH Z80 Assembler                     page 2
  57.  
  58.  
  59. Conditions  (i.e.  z  nz  c  nc pe po m  p)  are  standard  Zilog 
  60. mnemonics. For example
  61.  
  62.  
  63.      nz 5 call,
  64.  
  65. As  you  have  probably  noticed,  the  instructions  are  simply 
  66. standard Zilog mnemonics, followed by a comma.
  67.  
  68. All instructions are implemented.  Osborne users beware -- use of 
  69. in or out instructions will likely crash the system.
  70.  
  71. There  is  no label mechanism.   Of course,  you may use HERE  to 
  72. determine jump addresses,  but this is unwieldly.   Instead, four 
  73. control structures are implemented:
  74.  
  75.      if, else, then,
  76.      do, loop,
  77.      begin, until,
  78.      begin, while, repeat,
  79.  
  80. The  if,  until,  and while,  controls operate like the  standard 
  81. FORTH versions,  except that a condition is tested rather than  a 
  82. value.   The words if,  until,  and while,  must be preceded by a 
  83. condition  (e.g.  z nz) and the code preceding the word must  set 
  84. the flags appropriately.
  85.  
  86. The do,  loop,  structure generates a counted loop using the  Z80 
  87. djnz  instruction.   The  count must be placed in the b  register 
  88. before  the loop and must be in that register at  the  end.   The 
  89. count  may  be from 1 to 256 (0 is treated as  256).   Note  that 
  90. Software  Works FORTH requires that the bc register be unmodified 
  91. by a function, so be sure to save it.
  92.  
  93. Control structures may be nested to a depth of at least 10.
  94.  
  95. The  Z80  hardware stack is used as the data  stack  in  Software 
  96. Works  FORTH,  so  values may be removed or added with  pop,  and 
  97. push, instructions.
  98.  
  99. WARNING:  The  bc  register must be preserved in  Software  Works 
  100.           FORTH.   Failure to do this will almost certainly crash 
  101.           the system.
  102.  
  103.