home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / love / chap12.doc < prev    next >
Text File  |  1993-04-11  |  2KB  |  55 lines

  1. Chapter12               L.O.V.E. FORTH
  2.  
  3.  
  4.  
  5. 12.0 8086/8 Register Usage
  6.      ---------------------
  7.  
  8. The register usage is summarised as follows:
  9.  
  10.      SI - Forth interpretive pointer (IP)
  11.      SP - Parameter stack    }  sometimes these pointers are
  12.      BP - Return stack       }           exchanged
  13.  
  14.      CS - Points to code segment CS:
  15.      DS - Points to thread segment TS:
  16.      SS - Points to stack segment SS:
  17.      ES - Points to variable segment VS:
  18.  
  19.      DI - reserved for use as local variable stack pointer
  20.  
  21.      On entry to a word:
  22.  
  23.      BX - points to the compilation address of the word being
  24.                      executed
  25.      AX - is destroyed between words
  26.      CX, DX - may be used as scratch registers
  27.  
  28.  
  29. 12.1 Kernel examples of register usage
  30.      ---------------------------------
  31.  
  32. CODE LIT     ( -- N )
  33.       WORD LODS   AX PUSH   NEXT-JMP C;
  34.  
  35. ( LODS  always loads relative to DS = TS: )
  36. ( PUSH  stores relative to SS )
  37. ( all code executes relative to CS )
  38.  
  39. CODE @
  40.      BX POP   ES: [BX] PUSH   NEXT-JMP C;
  41. ( POP   always loads relative to SS )
  42. ( [BX]  must be overridden to fetch from ES: )
  43. (   PUSH always relative to SS)
  44.  
  45. CODE FILL            ( addr, count, value -- )
  46.     DX, DI MOV                             ( save value of DI )
  47.     AX POP    CX POP    DI POP             ( get parameters)
  48.     AH, AL MOV  CX, 1 SHR                  ( odd number of bytes ?)
  49.     IFU< BYTE STOS ( odd # bytes )  THEN   ( store odd one)
  50.     REP WORD STOS                          ( store the remainder)
  51.     DI, DX MOV NEXT-JMP C;                 ( restore DI)
  52.  
  53. ( POP   always loads relative to SS )
  54. ( STOS  always stores relative to ES  = VS: )
  55.