home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / tutor / l4p030 < prev    next >
Text File  |  1990-07-15  |  5KB  |  104 lines

  1.        ╔════════════════════════════════════════════════════╗
  2.        ║ Lesson 4 Part 030  F-PC 3.5 Tutorial by Jack Brown ║
  3.        ╚════════════════════════════════════════════════════╝
  4.  
  5.              ┌────────────────────────────────┐
  6.              │  Memory Organiziation in F-PC  │
  7.              └────────────────────────────────┘
  8.  
  9. We continue with our initial investigation of F-PC's memory
  10. organization.  We had, if you recall, discovered that every time we make
  11. a colon definition 5 bytes are used in Forths CODE segment. The first 3
  12. bytes consist of a machine language jump to Forths colon definition
  13. execution procedure and the last 2 bytes is a pointer to the lists of
  14. addresses ( in the LIST segment) which make up the word. There is one
  15. address in the list for each word in the colon definition. The Header
  16. segment contains the word definitions name along with some other
  17. information that we won't discuss just yet.
  18.  
  19. Now don't worry if you haven't followed all this.  Just be aware that
  20. every time you make a colon definition it is going to create you new
  21. definition by compiling information in the CODE segment, the HEADER
  22. segment and the LIST segment.  All we really want right now is to find
  23. where the next available free space is in the CODE segment.  The word
  24. that will do this for us is  HERE
  25.  
  26. If you are using F-PC version 3.50 like we are HERE should return a
  27. value around 74D8 hex or $74D8 (the dollar sign is often used to
  28. indicate a hex number).
  29.  
  30. In any case we can be fairly certain the we have some free memory
  31. located at $9000 and on upward.  At least that is what we will assume
  32. for the following exercises.  If you system returns a HERE greater than
  33. $9000 then increase the value for the exercises below to  $A000 or
  34. whatever you need to get at least $1000 beyond   HERE  !!!!
  35.  
  36. Here are the new words that we are going to investigate and exercise by
  37. using memory available at $9000 and beyond.  Warning!  If you are not
  38. working with memory beyond HERE your F-PC Forth system could very well
  39. crash and burn!
  40.  
  41. DUMP    ( adr n   -- ) Dump n bytes of memory starting at adr.
  42. HEX 9000 20 DUMP <enter>
  43. +---------+-------------------------------------------------+---------
  44. | SEG:OFF |  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F |012345678
  45. +---------+-------------------------------------------------+---------
  46. |308B:9000| 2C 00 AD 03 F2 03 C3 02 2E 00 DD 06 FF 02 28 00 |,.-.r.C..
  47. |308B:9010| 64 04 52 05 CE 03 CE 02 1C 03 12 00 EA 04 6B 04 |d.R.N.N..
  48. +---------+-------------------------------------------------+---------
  49.  
  50. This is a dump of the memory in the code segment starting at $9000.
  51. $308B is the address of the code segment in the PC's 1 megabyte address
  52. space and will be different on most machines.  The numbers you get in
  53. the body of the table will also be different because this area of memory
  54. has not been initialized to any particular value.
  55.  
  56. ERASE   ( adr n   -- ) Erase n bytes of memory starting at adr
  57.                        to zeros.
  58. 9000 20 ERASE  ok
  59. 9000 20 DUMP
  60. +---------+-------------------------------------------------+-----------
  61. | SEG:OFF |  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F |0123456789A
  62. +---------+-------------------------------------------------+-----------
  63. |308B:9000| 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |...........
  64. |308B:9010| 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |...........
  65. +---------+-------------------------------------------------+-----------
  66.  
  67. What we have done is  to clear 20 bytes of memory starting at $9000 hex
  68. to zeros.  Please be aware that we are using F-PC version 3.5 and that
  69. the graphics above are an approximation of what you will actually see.
  70. The part of the display to the far right is the ASCII representation of
  71. the actual bytes and has been truncated to 72 bytes for the message
  72. base.
  73.  
  74. FILL  ( adr n m   -- ) Fill n bytes of memory starting at adr
  75.                        with low 8 bits of m ( 0 - 255 ).
  76. 9000 20 AA FILL  9000 20 DUMP <enter>
  77. +---------+-------------------------------------------------+-----------
  78. | SEG:OFF |  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F |0123456789A
  79. +---------+-------------------------------------------------+-----------
  80. |308B:9000| AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA |***********
  81. |308B:9010| AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA |***********
  82. +---------+-------------------------------------------------+-----------
  83.  
  84.   !     ( n adr   -- ) Store 16b value n at address adr.
  85.   @     ( adr     n  ) Fetch 16b value at adr and leave as n.
  86.  
  87. 1234 9000 !  5678 9010 !  <enter> ok
  88. 9000 @ . <enter> 1234  ok
  89. 9010 @ . <enter> 5678  ok
  90. 9000 20  DUMP  <enter>
  91. +---------+-------------------------------------------------+-----------
  92. | SEG:OFF |  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F |0123456789A
  93. +---------+-------------------------------------------------+-----------
  94. |308B:9000| 34 12 AA AA AA AA AA AA AA AA AA AA AA AA AA AA |4.*********
  95. |308B:9010| 78 56 AA AA AA AA AA AA AA AA AA AA AA AA AA AA |xV*********
  96. +---------+-------------------------------------------------+-----------
  97.  
  98. 16 bit numbers are stored with the low byte at adr and the high byte at
  99. adr+1, this is convention for 6502 and 8086 CPUs,  68000 is reversed.
  100.  
  101. ┌────────────────────────────────────┐
  102. │  Please move to Lesson 4 Part 040  │
  103. └────────────────────────────────────┘
  104.