home *** CD-ROM | disk | FTP | other *** search
- ╔════════════════════════════════════════════════════╗
- ║ Lesson 4 Part 030 F-PC 3.5 Tutorial by Jack Brown ║
- ╚════════════════════════════════════════════════════╝
-
- ┌────────────────────────────────┐
- │ Memory Organiziation in F-PC │
- └────────────────────────────────┘
-
- We continue with our initial investigation of F-PC's memory
- organization. We had, if you recall, discovered that every time we make
- a colon definition 5 bytes are used in Forths CODE segment. The first 3
- bytes consist of a machine language jump to Forths colon definition
- execution procedure and the last 2 bytes is a pointer to the lists of
- addresses ( in the LIST segment) which make up the word. There is one
- address in the list for each word in the colon definition. The Header
- segment contains the word definitions name along with some other
- information that we won't discuss just yet.
-
- Now don't worry if you haven't followed all this. Just be aware that
- every time you make a colon definition it is going to create you new
- definition by compiling information in the CODE segment, the HEADER
- segment and the LIST segment. All we really want right now is to find
- where the next available free space is in the CODE segment. The word
- that will do this for us is HERE
-
- If you are using F-PC version 3.50 like we are HERE should return a
- value around 74D8 hex or $74D8 (the dollar sign is often used to
- indicate a hex number).
-
- In any case we can be fairly certain the we have some free memory
- located at $9000 and on upward. At least that is what we will assume
- for the following exercises. If you system returns a HERE greater than
- $9000 then increase the value for the exercises below to $A000 or
- whatever you need to get at least $1000 beyond HERE !!!!
-
- Here are the new words that we are going to investigate and exercise by
- using memory available at $9000 and beyond. Warning! If you are not
- working with memory beyond HERE your F-PC Forth system could very well
- crash and burn!
-
- DUMP ( adr n -- ) Dump n bytes of memory starting at adr.
- HEX 9000 20 DUMP <enter>
- +---------+-------------------------------------------------+---------
- | SEG:OFF | 0 1 2 3 4 5 6 7 8 9 A B C D E F |012345678
- +---------+-------------------------------------------------+---------
- |308B:9000| 2C 00 AD 03 F2 03 C3 02 2E 00 DD 06 FF 02 28 00 |,.-.r.C..
- |308B:9010| 64 04 52 05 CE 03 CE 02 1C 03 12 00 EA 04 6B 04 |d.R.N.N..
- +---------+-------------------------------------------------+---------
-
- This is a dump of the memory in the code segment starting at $9000.
- $308B is the address of the code segment in the PC's 1 megabyte address
- space and will be different on most machines. The numbers you get in
- the body of the table will also be different because this area of memory
- has not been initialized to any particular value.
-
- ERASE ( adr n -- ) Erase n bytes of memory starting at adr
- to zeros.
- 9000 20 ERASE ok
- 9000 20 DUMP
- +---------+-------------------------------------------------+-----------
- | SEG:OFF | 0 1 2 3 4 5 6 7 8 9 A B C D E F |0123456789A
- +---------+-------------------------------------------------+-----------
- |308B:9000| 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |...........
- |308B:9010| 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |...........
- +---------+-------------------------------------------------+-----------
-
- What we have done is to clear 20 bytes of memory starting at $9000 hex
- to zeros. Please be aware that we are using F-PC version 3.5 and that
- the graphics above are an approximation of what you will actually see.
- The part of the display to the far right is the ASCII representation of
- the actual bytes and has been truncated to 72 bytes for the message
- base.
-
- FILL ( adr n m -- ) Fill n bytes of memory starting at adr
- with low 8 bits of m ( 0 - 255 ).
- 9000 20 AA FILL 9000 20 DUMP <enter>
- +---------+-------------------------------------------------+-----------
- | SEG:OFF | 0 1 2 3 4 5 6 7 8 9 A B C D E F |0123456789A
- +---------+-------------------------------------------------+-----------
- |308B:9000| AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA |***********
- |308B:9010| AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA |***********
- +---------+-------------------------------------------------+-----------
-
- ! ( n adr -- ) Store 16b value n at address adr.
- @ ( adr n ) Fetch 16b value at adr and leave as n.
-
- 1234 9000 ! 5678 9010 ! <enter> ok
- 9000 @ . <enter> 1234 ok
- 9010 @ . <enter> 5678 ok
- 9000 20 DUMP <enter>
- +---------+-------------------------------------------------+-----------
- | SEG:OFF | 0 1 2 3 4 5 6 7 8 9 A B C D E F |0123456789A
- +---------+-------------------------------------------------+-----------
- |308B:9000| 34 12 AA AA AA AA AA AA AA AA AA AA AA AA AA AA |4.*********
- |308B:9010| 78 56 AA AA AA AA AA AA AA AA AA AA AA AA AA AA |xV*********
- +---------+-------------------------------------------------+-----------
-
- 16 bit numbers are stored with the low byte at adr and the high byte at
- adr+1, this is convention for 6502 and 8086 CPUs, 68000 is reversed.
-
- ┌────────────────────────────────────┐
- │ Please move to Lesson 4 Part 040 │
- └────────────────────────────────────┘
-