please dont rip this site

13. Virtual Memory

13.1. Basics
By the time you get there, the Reader has probably written a lot of programs. Much of them have been edited on a umbrella to improve them (see Section 2.5 ).
The spectators are so called. they are in virtual memory. Virtual memory is a memory that is complemented with a diskette file. The virtual word here is apparent. The virtual memory name reflects that the virtual memory blocks - although they are on a data carrier - are programmed to appear as if they were in memory. This is because we see it because

BLOCK (block number --- memory address)

word ensures that the block you are referring to is scanned into memory if it has not been there; from the recovered address we find the contents of the block in the memory. The block here is the physical unity of reading and writing, usually (as a disc) of a sector.
The AB / BUF system constant specifies how many blocks the block is. If we assume that there are text data in the virtual memory, it is possible to output the contents of a given block of numbers:

: BTYPE (block number ---)
   BLOCK (address)
   B / BUF (block address block)
   TYPE
;

Looking at the BTYPE word usually shows that the blocks contain a set of jewels; around the 4th round there are error messages (see section 13.3 ).
The word BLOCK:

  • scans the block with the specified number in the memory and returns the address of the scanned block;
  • or if the block is already in the memory due to a previous scan, it will search for it and enter its address.

In the latter case, we do not turn to the disc; saving time without having to pay attention to programming when writing.
The virtual memory blocks are interpreted by the interpreter as a so-called memory. in his block robots. BLOCK looks at whether there is any block in one of the block buffers; if found, then we get the block buffer address, if not, then scan, but in which buffer?
The answer is simple if there is an empty block buffer. However, block buffers are few in comparison to virtual memory blocks. Mostly, one of the blocked buffer blocks must be overwritten. What happens to the buffer for the puff? Are you discouraged or rewritten on the media?
This is what we decide for ourselves. If we do nothing, the contents of the buffer will not be restored, so just read the virtual memory. We want to rewrite a given block, after the block reference (BLOCK)

UPDATE (---)

so we announce it. This block will be "updated", so it will be modified. Words are a bit misleading; the contents of the block buffer will then be modified, and the media blocks will be later, when the buffer is needed, or whenever the modified buffer is reverted.

UPDATE always refers to the block that was last referred to as BLOCK.

(This simply happens that BLOCK puts the block number in the PREV system variable and UPDATE finds it there).
All modified blocks are a

FLUSH (---)

so we can write it out (for example, when we stand up from the machine). But if we want to do all that we have mixed in the block buffers, that is

EMPTY-BUFFERS (---)

we can start with a clean sheet; the EMPTY BUFFERS does not delete the buffers, but write the buffers' records.)
To make the texts stored in the virtual memory executable in the same way as the interpreter, the interpreter will consider all the block buffer buffers without having to rewrite (or modify the actual contents of the block buffers) such as the keypad, it depends (among others) that the interpreter always passes the word WORD to the next word to be interpreted. WORD works depending on the contents of the BLK system variable:

WORD records the IN system variable in the command buffer or in the block that is being recorded. After reading a word, the IN content increases with the word length so the WORD next will look for the next word.
BLOCK, UPDATE, FLUSH and EMPTY-BUFFERS are the basics of virtual memory management. The rest of this chapter will show how to use them through the FORTH basic words and the most basic words of a word processor.

13.2. Lightweight Basic Words
The size of the hoods is not the same as the block length; more than one block is usually needed to store a watch. How much is that in the given FORTH, that is the B / SCR system constant. In Fig-Forth, 8 blocks out of an umbrella. The blinds are on a continuous, sequential number block.
The number of screens, blocks and queues starts from 0.

Let's look at how LINE is the basic word that gives the title and length of the specified number of lines of the specified number of frames. So, for example, 0 2 (LINE) TYPE is the 0th digit of the 2nd screen, ie, it writes the top line of the screen.
To calculate the address of the line you are looking for (or be sure you are in the memory), we need to know which block it is in.
The number of the first block of the row containing the row: B / SCR * number of frames (because in the virtual memory it is preceded by an "umbrella" piece, each of which is a B / SCR block).
The row is preceded by a row number * number within the umbrella , so there are as many blocks as it can fit. That is: a

(line length * serial number) / block length

quantifies how many blocks from the beginning of the screen precedes the block containing our line and the remaining number of characters in the block. The line length is given by the C / L system constant.
After that the text of the program is:

: (LINE)
   > R
   C / L
   B / BUF
   * / MOD  
(Ref kernyõsz --- Address Length)
(number)
(Ref queue length)
(serial queue length block length)
(the remainder: the line within the block)
            (number of preventive characters)
      (the quotient: the
      number of blocks preceding the block)
R>
   B / SCR *
   +

   BLOCK
   +
   C / L
;   
(number of blocks)
(the starting point of
the row containing the line
)
(row starting line)
(row start
)

If we look at it better, (LINE) works even if the specified line is not on the specified umbrella (for example, if the 16 slots are looking for row 18 of our umbrellas and 0. quill, we get the same as the 1st window 2. ).
The LIST basic word list is the

.LINE (serial no. Number ---)

built on words; it prints the specified line. The .LINE call has not yet been learned

-TRAILING (title length --- address length2)

Basic word. A -TRAILING cuts off the spaces from the end of the string with its title and length; it changes the length so that the space element does not understand.

: .LINE (line number lane ---)
   (LINE)
   -TRAILING (to avoid having no excess)
   TYPE
;

FORTH editors often consist of operations for a current queue line. The number of the current screen is contained in the SCR system variable. For example, the LIST (see Section 2.5 ) also makes the listener visible in real time, ie places its number in the SCR variable.

: LIST
   DECIMAL CR
   DUP SCR! (we made the elephant accurately)
   . "SCR #". (write the number of the queue)
   16 0 DO (may be the queues)
      CR R 3 .R SPACE (line number)
      R SCR @ .LINE (row content)
   LOOP
   CR
;

13.3. Standard error handling
The FORTH parentheses start the ERROR word when the error is detected and the bug is waiting for the error number. ERROR's activity can vary depending on the value of the WARNING system variable:

We will learn to define our own interrupt procedure later (see chapter 14.4.3 ).
In all three cases, ERROR drains the vermet and incorporates the contents of the IN and BLK system variables. The error counts can be found in the appendix .
Most of our programs are

? ERROR (indicator error number)

is used for error reporting. The indicator indicates whether a specified number error has occurred. The ERROR source text:

: ERROR
   SWAP IF ERROR
        ELSE DROP
   ENDIF
;

Those who are interested in seeing many examples of what have been studied so far should read the source of the most important words of ERROR and ERROR:

: ERROR
   WARNING @
   0 <IF
     (ABORT)
   ENDIF 
(error line --- in blk)


(user interruption)
      (here we can only get WARNING)
      (not negative)
   HERE COUNT
   TYPE
   . "?"
   MESSAGE
   SP!
   IN @ BLK @
   QUIT
;
(we write the word that WORD)
(last read)

(this word writes the error message)
(this word drains the vermet)

: (ABORT)
   ABORT
;

(user interruption)

The error message is MESSAGE:

: MESSAGE
   WARNING @
   IF
     -DUP IF
       4 .LINE SPACE
     ENDIF
   ELSE
     "MSG £".
   ENDIF
;
(

if WARNING is not 0)
(if the error string is not 0)


(if WARNING 0)

13.4. Excerpts from a Editor
We will get to know one part of the editor, William F. Ragsdale, attached to fig-FORTH; as much as it is uncomfortable, but enough for the maintenance of the umbrellas. The editor's description can be found in Appendix C. Here we mainly deal with the construction of the words, the source text.
First of all, creating a dictionary containing the words of the editor is our job.

VOCABULARY IMMEDIATE EDITOR

This will be the search and chaining dictionary:

EDITOR DEFINITIONS

When writing the editor's words, we work in sixteen numerical systems:

HEX

The pad serves as a temporary storage of the text of the lines. Our first word, TEXT, reads a string of words from the spell and makes it into the pile in the form of a FORTH rope. The worm waits for the delimiter character of the text.

: TEXT
   HERE C / L 1+
   BLANKS      
   WORD
(c ---)
(over the dictionary)
(upload with spaces)
(read the text of the given)
     (with delimiter characters, transfer to PAD)
     (text, data to be provided to CMOVE)
   HERE
   PAD
   C / L 1+
   CMOVE
;
(where)
(where)
( where )

Our next building block is LINE, which tells you which row of the current queen is where it is. A viewer is current because its number is in the SCR variable.
The LINE checks whether the number received is between 0 and 15. Meanwhile, of course, he says that a watch is 16 rows.

: LINE
   DUP
   FFF0 AND
(serial number --- address)

(one number falls between 0 and 15)
      (if its hexadecimal shape is one-digit)
      (this gives the AND 0 bit per bit)
   17? ERROR

   SCR @
   (LINE)
   DROP
;
(if you do not get 0, you will get away)
(the program)
(line title)
(and length)

It is built on this

-MOVE (title line ---)

which copies a line from the specified address to the specified number of rows of the current quilt:

: -MOVE (address line ---)
   LINE (the address where we move)
   C / L CMOVE
   UPDATE
;

The first user word of the editor is E (erase), which overwrites the specified number of lines with spaces:

: E (line ---)
   LINE (the address of the line to be deleted)
   C / L BLANKS
   UPDATE
;

With the word S (spread), the specified line can be dumped by lowering the contents below the rows below and filling the space with spaces. The last line of the umbrella is lost.

: S
   DUP 1-

   0E
   DO
     R LINE
     R 1+
     -MOVE
   -1 + LOOP

   E
;
(No. ---)
(the first line, which does not require)
(move)
(the last line, which is moved)
(the cycle progresses from behind)
(moved row)
(write this line)

(A copy of the serial number on the stack )
(left)
(deleting a line with spaces)

AH (hold) retrieves the specified number of lines of the current umbrella into the pad, in the form of FORTH.

: H
   LINE
   PAD 1+
   C / L
   DUP PAD C!
   CMOVE
;
(sort ---)
(the title from which
we copied)

(duplicate ) (lengthwise to the beginning of the pad)

AD (delete; delete) will delete the specified number of lines; the umbrellas underneath are moving up one up, and the last row is overwritten. The deleted line remains in the pad.

: D
   DUP H
   0F      DOUBLE
   ROT
   DO
     R 1+
     LINE
R -MOVE
   LOOP
   E
;
(
the line goes to the pad)
(last row number)
(

the row is on the top of the stack) (this row goes up)


(the stack has a copy of 0F)
(deleting the last line with spaces)

R (replace) replaces the specified frame with the text stored in the pad.

: R (
   sort ---) PAD 1+ SWAP -MOVE;

AP (put; place) overwrites the specified search string with the text that is written after P (end of the line):

: P
  1
  TEXT
  R
;
(No. ---)
(1 character code is not on your keyboard)
(TEXT will read until the end of the line)
(TEXT read the pew, R copy here)

The word I (insert) inserts the text in the pad just as in R, but pushes the line down with the underside before overwriting.

: I (sort ---)
   DUP SR;

Another word that handles the entire screen: CLEAR (ornate number), this clears the specified umbrella.

: CLEAR
   SCR!
   10 0 DO
     FORTH
     R
     EDITOR
     E
   LOOP
;
( row = )
(the screen becomes actual)
(row 16)
(word R from the FORTH dictionary)
(should be taken)

What was that about?
Summary of Chapter 13

The words learned:

BLOCK (n --- address)
Returns the memory address of the block buffer containing the nth block. If the block is not in the memory, it will be read in the block buffer that was last mentioned last. If you have edited a revised puff, it will first copy the content to the virtual memory.
UPDATE (---)
Modified indicates the block that was last referred to as BLOCK (the block number is found in the PREV system variable). This means that the interpreter will rewrite the block into the virtual memory before using the block buffer containing it.
FLUSH (---) Write the modified blocks in the virtual memory.
EMPTY-BUFFERS (---)
Changes the register of block buffers; all of them are considered blank (without modifying the modified blocks in the virtual memory).
PREV ( --- title ) In this system variable, the number of the block that BLOCK has last referenced is retained.
B / BUF (--- n) Constant system; the block length bytes.

The system variables used by the WORD:

BLK ( --- title )
The number of the block from which the WORD reads the influence. If 0, then my influence comes from the terminal, WORD reads from the command buffer.
TIB ( --- title ) A system variable with the command buffer address.
TENDON ( --- title ) Shows the WORD where the block buffer or command buffer contains the closest read.

Kernyõkezelés:

B / SCR (--- n) System constant: the number of blocks in a single window.
C / L (--- n) System Constance: the length of the grid rows.
(LINE) (row nose --- title length) Specifies the memory address and length of the specified row of specified number of umbrellas.
.lin (row nose ---) Write the specified line.
SCR ( --- title ) System variable; the editors use to store the current number of people.

Error handling:

ERROR (error-blk in)
Procedure to be followed when a given number of errors are detected. If the value of the WARNING variable is 1, it writes an error number from the beginning of the fourth memory of the virtual memory as a diagnostic error. (The sequence number may be negative or you can move beyond the 4th floor.) If WARNING is 0, the error is only identified with the number of the error message. If WARNING is -1, the word (ABORT) is executed, which we can modify ourselves (see section 14.4.3 ). We get the contents of the BLK and IN variables on the vermin to identify the error. Fault management ends with QUIT.
(ABORT)  
"User Defined Interruption", see 14.4.3. chapter . If you do not define an interrupt procedure, the word ABORT will be executed.
WARNING ( --- title ) System variable; contains information on how to handle error handling (see ERROR).
? ERROR (error f --- ---) If f is true, it starts the error handling procedure for the specified serial number.
MESSAGE (n ---)
In response to the WARNING value, the error message is output to the specified serial number: if WARNING is 0, the serial number, if not, is the nth row of row 4 of line 4.

Other words:

-TRAILING (title length --- address length2)
Change the length of the string with its title and length so as not to include the spaces at the end of the text.
ABORT  
Empties the vermes, the search and the chaining dictionary to FORTH, and sets the conversion count to 10. Interrupting the line or bracket that is being interpreted will wait for a new command line.
SP!   Emptying the stack.

The editor's words, see Appendix C .

Examples

Before trying out task solutions, you might want to put a virtual memory off of a virtual memory. So people are experimenting more courageously.

13.1. (After Leo Brodie, freely). There are ladies in the 25th virtual memory, one on each line.

At the beginning of the line, the lady's name, starting from the 21st character, is the color of her, starting with the 40th character, her eye color (so all three fields are 20 characters long). Write a LEVEL (n ---) word waiting for the line number on the vermen and print the following letter:

     Dear <name>!
Lazba jovok, if you remember <eye color>
your eyes, <hair color> your hair. Come tomorrow,
pick up your clothes, so you're gonna have a pretty
eye on
      Leo

For example:

The letter writer may be somewhat instable: it changes the starting position of the eye, intends to start the lines of the letter or does not want to use the 25th cap. Therefore, highlighting the name, hair color and eye color is emphasized in one word; we also discuss the starting address of the line containing the lady. So it will be easy to change when someone remembers you.

0 VARIABLE LIN
: SOR (--- LINE) LIN @ 25 (LINE) DROP;
: .NEV SOR 20 -TRAILING TYPE;
: .HAJ SOR 20 + 20 -TRAILING TYPE;
: SEM 40 + 20 -TRAILING TYPE;
: UJSOR CR 10 SPACES;

In addition to filling in the mail, the main program should provide the LIN variable upload:

: LEVEL
  LIN!
  CR UJSOR 5 SPACES
  "Dear" .NEV. "!"
  CR UJSOR "Lazba jovok, if you remember me" I'm UJSOR
  "your eyes," .HAY "your hair, come tomorrow,"
  UJSOR. "Pick up" I AM ", clothes so"
  UJSOR. " "
  UJSOR 7 SPACES. "Leo" CR
;

13.2. How to write the word INDEX (from ig ---), which lists the row 0 (including "umbrella" and "up") between the two specified borders. Keep in mind if you press a key on your keyboard.

: INDEX (tol ig ---)
   1 + SWAP DO
      CR 0 R (LINE) -TRAILING TYPE
      ? TERMINAL IF LEAVE ENDIF
   LOOP
;

13.3. What can be the source of -TRAILING?
The FIG solution:

: -TRAILING
  DUP 0 DO
    2DUP +
    1- C @
    BL - IF
      LEAVE
    ELSE
      1-
    ENDIF
  LOOP
;
(Title length --- Address hossz1)
(a stack of address length)
(after the title string)
(last character of the string)
(No spaces,)
(We are ready for slaughter)
(if space bar)
(further abbreviated)

file: /Techref/language/FORTH/z80fig-Forth1_1g_files/virtual_memory.htm, 80KB, , updated: 2018/11/8 21:01, local time: 2024/5/23 09:34,
TOP NEW HELP FIND: 
44.210.83.132:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://piclist.com/techref/language/FORTH/z80fig-Forth1_1g_files/virtual_memory.htm"> 13. Virtual Memory </A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

  PICList 2024 contributors:
o List host: MIT, Site host massmind.org, Top posters @none found
- Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
 

Welcome to piclist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .