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

  1. Chapter16               L.O.V.E. FORTH
  2.  
  3.  
  4.  
  5. 16.0  L.O.V.E. Forth Interactive System Map
  6.       -------------------------------------
  7.  
  8.  
  9. relative address                  description          actual segment
  10.  
  11. 0000:0000       ┌───────────┐     DOS PSP              GET:PSP or GET:CS
  12. 0000:0100       ├───────────┤
  13.                 │           │     CODE SEGMENT
  14.                 ├─ CS:HERE ─┤
  15.                 │           │
  16.                 │           │
  17.                 │           │
  18.                 │           │
  19.                 │ ^virtual^ │
  20. 1000:0000       ╞═══════════╡
  21.                 │           │     THREAD SEGMENT       GET:TS
  22.                 │           │
  23.                 ├─ TS:HERE ─┤
  24.                 │           │
  25.                 │           │
  26.                 │           │
  27.                 │           │
  28.                 │ ^virtual^ │
  29. 2000:0000       ╞═══════════╡     DATA (VARIABLES)     GET:VS
  30.                 │           │     SEGMENT
  31.                 ├── HERE ───┤
  32.         HERE+54h├── PAD  ───┤
  33.                 │           │
  34.                 │           │
  35.                 │ ^virtual^ │
  36.                 ├─ FIRST ───┤
  37.                 │  LIMIT    │ block buffers
  38. 3000:0000       ╞═══════════╡
  39.                 │           │     HEAD SEGMENT         GET:HS
  40.                 │           │
  41.                 │           │
  42.                 ├─ HS:HERE ─┤
  43.                 │           │
  44.                 │           │
  45.                 │           │
  46.                 │ ^virtual^ │
  47. 4000:0000       ╞═══════════╡
  48.                 ├─ SS:HERE ─┤     STACK SEGMENT        GET:SS
  49.                 │           │
  50.                 │           │
  51.                 │           │
  52.                 │           │
  53. 4000:DFF0       ├───────────┤ ^vocabulary stack   (initial addresses
  54. 4000:EFF0       ├─ RPBOT ───┤ ^return stack                given)
  55. 4000:FFF0       ├─ SPBOT ───┤ ^parameter stack
  56. 5000:0000       ╞═══════════╡
  57.                 │           │     HEAP SEGMENT         GET:HEAP
  58.                 │           │
  59.                 /           /
  60.                 │           │ at least MINHEAP
  61.                 └───────────┘    paragraphs
  62.  
  63.    Notes: * GET:CS   and   GET:PSP   return the same segment on
  64.           * version 1.28 and prior versions
  65.           * ^virtual^ vocabularies are at the top of memory, if present
  66.           * stacks work downward from high memory
  67.  
  68.  
  69. 16.1 L.O.V.E. FORTH APPLICATION Map
  70.      ------------------------------
  71.  
  72. relative address                  description          actual segment
  73.  
  74. 0000:0000       ┌───────────┐     DOS PSP              GET:PSP  GET:CS
  75. 0000:0100       ├───────────┤
  76.                 │           │     CODE SEGMENT
  77.                 ├─ CS:HERE ─┤
  78. ????:0000       ╞═══════════╡
  79.                 │           │     THREAD SEGMENT       GET:TS
  80.                 │           │
  81.                 ├─ TS:HERE ─┤
  82. ????:0000       ╞═══════════╡     DATA (VARIABLES)     GET:VS
  83.                 │           │     SEGMENT
  84.                 ├── HERE ───┤
  85.         HERE+54h├── PAD  ───┤
  86.          PAD+50h├─ FIRST ───┤
  87.                 │  LIMIT    │ block buffers
  88. ????:0000       ╞═══════════╡
  89.                 ├─ SS:HERE ─┤     STACK SEGMENT        GET:SS
  90. ????:SS:HERE    ├───────────┤
  91. ????:  "  +1000h├─ RPBOT ───┤ ^return stack
  92. ????:  "  +2000h├─ SPBOT ───┤ ^parameter stack
  93. ????:0000       ╞═══════════╡
  94.                 │           │     HEAP SEGMENT         GET:HEAP
  95.                 │           │
  96.                 /           /
  97.                 │           │ at least MINHEAP
  98.                 └───────────┘    paragraphs
  99.  
  100. Notes: * segments are packed to the nearest paragraph above their
  101.            respective xx:  HERE
  102.        * GET:HS   and   HS:HERE   are undefined
  103.        * vocabulary stack does not exist
  104.        * return and parameter stacks are allocated above   SS:HERE
  105.  
  106.  
  107. 16.2 Segmentation Examples
  108.      ---------------------
  109.  
  110. Notes: * all addresses are 16 bits (cell)
  111.        * head segment can be eliminated from applications
  112.        * head segment form is subject to change in future versions
  113.  
  114.    CODE Word Example
  115.  
  116.         ┌────/─┬─────────────────────────┬───────────────────────/──┐
  117.    CS:  │      │ ..code .. code .. [next]│                          │
  118.         └────/─┴─────────────────────────┴───────────────────────/──┘
  119.                ^address xxxx
  120.  
  121.         ┌────/─┬────┬────────────────────────────────────────────/──┐
  122.    TS:  │      │xxxx│                                               │
  123.         └────/─┴────┴────────────────────────────────────────────/──┘
  124.                ^ compilation address yy
  125.                  (cell points to code)
  126.                                                 (VS: not relavent)
  127.  
  128.         ┌────/─╥────┬─────────┬──┬────┬──╥───────────────────────/──┐
  129.    HS:  │      ║link│cnt name │yy│xxxx│  ║                          │
  130.         └────/─╨────┴─────────┴──┴────┴──╨───────────────────────/──┘
  131.                     ^         ^pointers to code, compilation addr, etc
  132.                     ^name field address
  133.  
  134.  
  135. 16.3 COLON Word Example
  136.      ------------------
  137.  
  138.     ┌────/─┬─────────────────────────────┬───────────────────/──┐
  139.    CS:  │      │ colon nesting code .. [next]│                      │
  140.         └────/─┴─────────────────────────────┴───────────────────/──┘
  141.                ^address *col*
  142.                       Nesting code is common to all colon words.
  143.  
  144.         ┌─╥──╥───╥─╥─/───╥─────┬────┬────┬────╥──────────────────/──┐
  145.    TS:  │ ║  ║   ║ ║     ║*col*│ zz │ pp │EXIT║                     │
  146.         └─╨──╨───╨─╨─/───╨─────┴────┴────┴────╨──────────────────/──┘
  147.           ^pp    ^zz     ^compilation address qq
  148.                           (points to code)
  149.  
  150.                 pp, zz  compilation addresses of other words (cell)
  151.                 EXIT    compilation address of EXIT
  152.  
  153.                                                   (VS: not relavent)
  154.  
  155.         ┌────/─╥────┬─────────┬──┬───┬──╥────────────────────────/──┐
  156.    HS:  │      ║link│cnt name │qq│   │  ║                           │
  157.         └────/─╨────┴─────────┴──┴───┴──╨────────────────────────/──┘
  158.                     ^         ^pointers to code, compilation addr, etc
  159.                     ^name field address
  160.  
  161.  
  162. 16.4 VARIABLE Example
  163.      ----------------
  164.  
  165.  
  166.    Note: A   VARIABLE   or   CREATED   word is really just a  CONSTANT  that
  167.          returns an address
  168.  
  169.         ┌────/─┬───────────────────────┬─────────────────────────/──┐
  170.    CS:  │      │ constant code.. [next]│                            │
  171.         └────/─┴───────────────────────┴─────────────────────────/──┘
  172.                ^address *con*
  173.                       Constant code is common to all CONSTANTs,
  174.                                 VARIABLEs and CREATEd words
  175.  
  176.         ┌───────/───╥─────┬────╥─────────────────────────────────/──┐
  177.    TS:  │           ║*con*│aaaa║                                    │
  178.         └───────/───╨─────┴────╨─────────────────────────────────/──┘
  179.                     ^     ^thread segment parameter field
  180.                     ^       aaaa = CONSTANT data or VARIABLE address
  181.                     ^compilation address vv
  182.                        (points to code)
  183.  
  184.         ┌───────/───────╥────────────────────────────╥───────────/──┐
  185.    VS:  │               ║  ... ALLOTed data space .. ║              │
  186.         └───────/───────╨────────────────────────────╨───────────/──┘
  187.                         aaaa
  188.  
  189.  
  190.         ┌────/─╥────┬─────────┬──┬──┬────╥────────────────────────/──┐
  191.    HS:  │      ║link│cnt name │vv│  │aaaa║                           │
  192.         └────/─╨────┴─────────┴──┴──┴────╨────────────────────────/──┘
  193.                     ^         ^pointers to code, compilation addr, etc
  194.                     ^name field address