Tiny BASIC Manual. By Lee Davison.

Introduction

This is my HTMLised version of the manual for the MPF-1 BASIC interpreter.

The original manual is printed as a monochrome A5 size booklet. Diagrams are simple and where the keys or display are shown they are just boxed text. In this version I've replaced the diagrams with colour pictures and the key and display boxes with small, in-line, graphics. Shifted keys are shown with RED text in the graphic.

FOR example ..

"After the key is pressed, the LED display display will show ."

I've also tried to make sense of the translated into English phrases where appropriate, e.g.

"But, we just need to press when we intend to run from the 50 line number of the statement not to go back to the first line."

.. becomes ..

"To run the program from line 50, and not the first line, we just need to press ."

.. after a while though your brain goes numb so there's probably quite a few I missed.

So, onward to the manual.

The Manual
TABLE OF CONTENTS
 
I.Introduction5
 
II.MPF-I BASIC Interpreter 9
2.1How to install the BASIC Interpreter 9
2.2Keyboard use and the display 10
2.3Program editing16
2.4Cassette storage 18
2.5Immediate instructions 19
 
III.Summary of BASIC 21
3.1Variables21
3.2Operators21
3.3MPF BASIC Syntax grammar table 22
3.4System RAM areas of BASIC-MPF 25
 
IV.Introduction to programming 27
4.1Flow charts 27
4.2Problems with solutions 29
4.3Error codes33
4.4Examples34

I. Introduction

    BASIC is the most popular high level computer language used by many of today's computers. BASIC stands for Biginners All-purpose Symbolic Instruction Code. However, it should not be assumed that the BASIC language is only used by beginners and has no application in the real world. On the contrary, BASIC is of major importance in the world of business, and a large number of business systems programs are written in this language. The major advantage is that a programmer can produce a highly complex program in a fraction of the time taken to develop the same program in many other languages.

    The Micro-Professor, with it's powerful expansion capabilities, has been developed by Multitech Industrial Corporation to execute Z-80 machine language. To help the Micro-Professor user learn BASIC programming Multitech presents the Micro-Professor BASIC Interpreter.

Specifications:

(1)

The language used on the MPF-I is composed of several different types of words. The word types are:

  • Statements
  • Commands
  • Variables
  • (2)

    A 2K Byte BASIC Interpreter.

    (3)

    A 34 key BASIC name plate that overlays the original MPF-I keyboard.

    (4)

    Summary of BASIC commands and statements

    (a)Commands

    RUN - Execute the current program.

    LIST - Print out the current program to display.

    LOAD - Load a program from the casette tape.

    SAVE - Save a program on the casette tape.

    CONTINUE - Continue after STOP or PRINT.

    NEW - Clear memory to allow a new program to be written.

    (b)Statements

    PRINT - Output information to display.

    INPUT - Allow user input.

    LET - Assign a numerical value to a variable.

    CALL - Call a machine-code routine.

    GOTO - Jump to a given line.

    GOSUB - Jump to subroutine.

    RETURN - Return to main program from a subroutine.

    IF...THEN - Allow statement to be executed conditionally.

    FOR...TO - Set the parameters for loop execution.

    NEXT - End a FOR...TO statement.

    STOP - Force return to the command mode.

    (5)Variables
    (a)

    Numeric variables are the only type used in MPF-I BASIC.

    (b)

    Variables can only hold "integer" or whole number values such as 235 or -3451.

    (c)

    Limit: The limit for MPF-I BASIC is from -32767 to 32767.

    (d)

    Variable name: The length may be one or two characters. If the length is one character it must be one of the letters A-F. If the length is 2 characters the first must be one of the letters A-F and the second must be one of the numeric digits, 0-9.

    (6)Memory Variable
    M:

    The format is M <decimal>
    where decimal is a hexadecimal memory address.
    [Line no.] LET M <decimal> = <value>
    To write a byte into the specified memory location.
    [Line no.] LET <variable> = M <decimal>
    Assign variable with the contents of the specified memory location.

    (7)I/O Port Variable
    P:

    The format is P <decimal>
    where decimal is a hexadecimal I/O port address.
    [Line no.] LET P <decimal> = <value>
    Output a byte to the specified I/O port.
    [Line no.] LET <variable> = P <decimal>
    Assign variable with the contents of the specified I/O port.

    II. MPF-I BASIC Interpreter

        This chapter must be read very carefully, including how to install the BASIC Interpreter, how to use the keyboard and display, how to edit programs and how to use a cassette for storing or retrieving programs.

    2.1 How to Install the BASIC Interpreter

        The MPF-I BASIC Interpreter with a total length 2K bytes is stored in an EPROM, either a TMS2516 or an Intel 2716. Another option is the MPF-IB monitor with built-in BASIC Interpreter in a 4K byte EPROM, a TMS2532. On the MPF-I there is an IC location for memory expansion, ROM or RAM, marked U7, see the diagram below. The address range of U7 is from $2000 to $27FF. Before inserting the EPROM in the socket at U7, insure that the pin 1 of of EPROM is towards the top of the board and the MPF-I is turned off.

    NOTE: Care should be taken when inserting EPROM as the pins are fragile and will bend easily if not properly aligned.

        Overlay the MPF-I keyboard with the BASIC name plate. Next key in , or key in if using the 4K byte monitor. The LED display will show , this stands for BASIC Ready, the rightmost digit is a decimal point, which is the CURSOR. Now the MPF-I is under the control of the BASIC Interpreter.

    2.2 Keyboard use and the display

        The diagram above is the keyboard overlay for the MPF-I BASIC Interpreter. There are 34 keys but some keys have two different meanings. We can divide these 34 keys into the following groups:

    (1)

    Key: Reset the MPF-I and return control to the MPF-I monitor.

    (2)

    Key: To select cursor control key functions and operator keys.

    (3)

    Alphabetic Keys: , , , , ,

    (4)

    Numeric Keys: , , , , , , , , ,

    (5)

    Operator Keys: , , , , , , , , , , . The operators are accessed by using the key.

    (6)

    Cursor keys: , , , . The cursor keys are accessed by using the key.

    (7)

    Command keys: , , , , , , .

    (8)

    Statement keys: , , , , , , , , , , , , .

    (9)

    Delete keys: , used to delete the letter at the cursor. , used to delete the current line.

    (10)

    Special variable keys: and , accessed by using the key.

        The keyword concept is utilised in the BASIC program. Some keys stand for complete words, these keys are convenient to use and save typing time, there is a total of 19 keywords in MPF-BASIC. When the MPF-I is under the control of the BASIC Interpreter, the LED display will show . After the key is pressed, the LED display will show . When is pressed, the LED display will show .

        The 19 keywords will constitute the majority of the statements in your computer programs, and each statement will begin on a new line with a unique line number to identify it. Try the following ..

        10 PRINT A

        The first two characters "10" are the line number, ten. To enter this like the sequence of keys is . The corresponding display will be as follows:

    Display
    Before any key is pressed
    Key in
    Key in
    Key in
    Key in
    Key in

        The word syntax as used in programming relates to the order of keywords and characters in statements. In English syntax means the pattern of sentences and phrases that are constructed from words. In BASIC the syntax is checked to see if each BASIC statement has been constructed correctly. The MPF-I BASIC checks for syntax in two ways, first checking is done as each part of a BASIC statement is entered, secondly after the key is pressed, the entire line is checked for correct syntax.

    Try typing

        5 LET A=1

    During the statement entry, the syntax will be checked.

        If the key is pressed instead of the key, the display will show after the key is pressed, "E" means error, "2" is the Error Code. By means of pressing , , and keys, the statement can be corrected as shown below.

    Display
    Before any key is pressed
    Key in
    Key in
    Key in
    Key in
    Key in
    Key in
    Key in
    Key in
    Key in

        The program now stored in the program memory is ..

             5 LET A=1
            10 PRINT A

        Suppose we want to execute this program, we should press and . To run the program from line 50, and not the first line, we just need to press . The corresponding display is shown below.

    Display
    Before any key is pressed
    Key in
    Key in
    Key in

        Following is the key processing and display format.

     

    The following should be noted when using the BASIC Interpreter.

     
    1.

    After users overlay the MPF-I keyboard with the BASIC keyboard overlay and key in , or for 4K monitor, the BASIC Interpreter will clear the RAM buffer from $1800 to $1FAD. This will set the contents of each buffer byte to be zero. Then it will set the value of memory address $18E7 to be $FF as the delimiter. If instead the user sets the starting address to $2017, or $0817 for the 4K monitor, and presses the key, BASIC can be restarted without destroying the user program.

     
    2.

    The storage areas of user's program begins at the memory address $18E8 and is terminated by a $FF delimiter. For example, if users key in the two following statements

    	10 LET A5 = 180
    	20 PRINT A5
    

    The BASIC Interpreter will convert the statements into the corresponding BASIC internal code, see page 24 for a full list of BASICs internal codes. The previous two statements occupy 18 bytes of memory.

    	18E7	FF		Delimiter
    	18E8	00	0	Line number first digit
    	18E9	01	1	Line number second digit
    	18EA	00	0	Line number third digit
    	18EB	1F	LET
    	18EC	0A	A
    	18ED	05	5
    	18EE	18	=
    	18EF	00	0
    	18F0	00	0
    	18F1	01	1
    	18F2	08	8
    	18F3	80	0	b7 set indicates end of statement
    	18F4	00	0	Line number first digit
    	18F5	02	2	Line number second digit
    	18F6	00	0	Line number third digit
    	18F7	20	PRINT
    	18F8	0A	A
    	18F9	85	5	b7 set indicates end of statement
    	18FA	FF		Delimiter
    

    The BASIC Interpreter sets bit 7 of the last byte of each statement as the end of statement marker. From the above example we know that $18F3 has a value of $00 but will be $80 in memory as it is the last byte in the statement.

     
    3.

    The stack pointer of MPF-BASIC is $1F9F because the user stack of the MPF-I is $1F9F. So, if the user's program becomes so large that it extends beyond $1F9F, the BASIC Interpreter's program will be overwritten.

    2.3 Program editing

        Before editing a program, we can check any statement by using the LIST command. For example, if we want to check statement 10 of the above program we can do so by pressing . Statement 10 will be scrolled from right to left across the display and then the display will show . We can leave LIST mode by pressing the key and the LED display will show to show that BASIC is ready. As the statement is being scrolled from right to left pressing any key, except RESET, will pause the shifting. Shifting may be resumed by again pressing any key, except RESET. By repeatedly pressing a key, for example the key, you may pause and resume the shifting action of the display several times. Because each BASIC statement has a unique line number to identify it we can edit the request statement by replacing it with a new statement. For example, if we want to change statement 10 to

    	10 LET C = A
    

    The keys we should press are . After the key is pressed, the old statement 10 PRINT A will be removed from the program and the new statement 10 LET C = A will be stored in it's place. The program in program memory now becomes

    	 5 LET A = 1
    	10 LET C = A
    

        If we want to insert a statement 7 PRINT A between statement 5 and 10, we can press following keys: . After the key is pressed, the statement 10 LET C = A will move backward from original memory location to leave spave for the statement 7 PRINT A. Statement 7 will be inserted between statement 5 and statement 10. Now the program stored in the program memory becomes

    	 5 LET A = 1
    	 7 PRINT A
    	10 LET C = A
    

        We can delete any statement from the program memory by pressing its line number and the key. For example, we want to delete statement 10 from the above program, press the keys as follows, . Now the program stored in memory is

    	 5 LET A = 1
    	 7 PRINT A
    

    2.4 Cassette Storage
     
    (1)

    Saving Program onto Tape
    The program in the memory can be saved to tape by pressing <filename> .
    Where:

    (a)

    Filename is a decimal number from 0 to 255.

    (b)

    Before pressing , you must connect the microphone of the recorder to MIC jack of MPF-I and press PLAY and REC on the recorder to start recording.

        The display is blank during transfer, the TONE-OUT LED is on and the tone sounds. After recording, the display will show .

    (2)

    Loading program from Tape
    A program stored on tape can be loaded into memory by pressing <filename> .
    Where:

    (a)

    Filename is a decimal number from 0 to 255.

    (b)

    Turn the volume of recorder to Maximim.

    (c)

    Press , and finally start the recorder by pressing PLAY.

        At the beginning, the display is . When the requested file is found the display becomes . When the program was saved on the tape an additional value called a checksum was recorded. This value is produced by adding up all the bytes in the program. As the program is read back into the MPF-I memory a new checksum is calculated. If the newly calculated checksum doesn't match the check sum from the tape, an error has occured and the display will show . Control will now be passed to the monitor. If the checksum generated when the program is read from the tape matches the checksum on the tape, then the last input byte will be displayed.

    2.5 Immediate Instruction

        A statement entered without a line number will executed immediately after the key is pressed. Immediate instructions allow you to use the Micro-Professor as a simple integer calculator. The procedure to compute 3 x 8 is shown below.

    The display will show . To return to press .

    III. Summary of BASIC
    3.1

    Variables

     
    (a)

    Numeric variables are the only variable type used in MPF-I BASIC.

    (b)

    Variables can only hold integer or whole number values.

    (c)

    Limit: The limit for MPF-I BASIC integers is from -32767 to 32767.

    (d)

    Variable name: The length may be one or two characters. If the length is one character it must be one of the letters A-F. If the length is 2 characters the first must be one of the letters A-F and the second must be one of the numeric digits, 0-9.

     
    3.2

    Operators

     
    SymbolFunction
    =Assignment
    -Negation or subtraction
    +Addition
    *Multiplication
    /Division
    **Raising to a power
    =Equal
    <Less than
    >Greater than
    ~Bitwise NOT, 1's complement
    ^Bitwise AND
    vBitwise OR

    3.3  MPF BASIC Syntax Grammar Table

    *****************************************************************
    *                                                               *
    *            MPF  BASIC  Syntax  Grammar  Table                 *
    *                                                               *
    *****************************************************************
    
    digit   ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
    
    letter  ::= A | B | C | D | E | F
    
    operator::= ~ | ^ | v | + | - | * | / | **
    
    unary   ::= + | - | ~
    
    relation::= > | = | <
    
    decimal ::= <digit> | +<digit> | -<digit> | <decimal><digit>
                Range : -32767 to +32767 inclusive
    
    filename::= <decimal>
                Range : 0 to 255 inclusive
    
    portaddr::= <decimal>
                Range : 0 to 255 inclusive
    
    variable::= <letter> | <letter><digit>
    
    memory  ::= M <decimal>
    
    port    ::= P <decimal>
    
    line#   ::= <digit> | <line#><digit>
                Range : 1 to 3 digit
    
    value   ::= <decimal> | <variable>
    
    VMP_val ::= [unary]<value> | <memory> | <port>
    
    VMP_var ::= <variable> | <memory> | <port>
    
    express ::= <value> | <value> <operator> <value>
    
    VMP_exp ::= [unary]<VMP_val> | <VMP_exp> <operator> <VMP_exp>
    
    *** CLAUSE ***
    
    LET_clause      ::= [<line#>] LET <VMP_var> = <VMP_exp>
    
    PRINT_clause    ::= [<line#>] PRINT <VMP_exp>
    
    INPUT_clause    ::= [<line#>] INPUT <variable>
    
    NEXT_clause     ::= [<line#>] NEXT <variable>
    
    GOSUB_clause    ::= [<line#>] GOSUB <line#>
    
    RETURN_clause   ::= [<line#>] RET
    
    GOTO_clause     ::= [<line#>] GOTO <line#>
    
    FOR_clause      ::= [<line#>] FOR <variable> = <value> TO <value>
    
    IF_clause       ::= [<line#>] IF <VMP_exp><relation><VMP_exp> THEN <line#>
    CALL_clause     ::= [<line#>] CALL <decimal>
    
    STOP_clause     ::= [<line#>] STOP
    
    *** COMMAND ***
    
    RUN_command     ::= RUN [<line#>]
    
    LIST_command    ::= LIST [<line#>]
    
    SAVE_command    ::= SAVE <filename>
    
    LOAD_command    ::= LOAD <filename>
    
    NEW_command     ::= NEW
    
    CONTINUE_command::= CONT
    
    DELETE_command  ::= DEL
    
    CLEAR_command   ::= CLR
    
    *****************************************************************
    *                                                               *
    *            MPF  BASIC  Internal  Code  Table                  *
    *                                                               *
    *****************************************************************
     Code    Mean    Code    Mean    Code    Mean    Code    Mean
     (hex)           (hex)           (hex)           (hex)
     00      0       10      NOT     20      PRINT   30      delete
     01      1       11      AND     21      INPUT   31      clear
     02      2       12      OR      22      NEXT    32      enter
     03      3       13      +       23      GOSUB   33      (left)
     04      4       14      -       24      RET     34      (right)
     05      5       15      *       25      GOTO    35      (down)
     06      6       16      /       26      FOR     36      (up)
     07      7       17      **      27      IF
     08      8       18      =       28      CALL
     09      9       19      <       29      STOP
     0A      A       1A      >       2A      run
     0B      B       1B      M       2B      list
     0C      C       1C      P       2C      save
     0D      D       1D      TO      2D      load
     0E      E       1E      THEN    2E      new
     0F      F       1F      LET     2F      cont
    

    3.4 System RAM Areas of BASIC-MPF

     1800		ORG	$1800
     1800	VARBUF:	DEFS	2* (6*$10+6)	; variables buffer
     18CC		DEFS	1
     18CD	LINBUF:	DEFS	21		; line buffer
     18E2	FLAG:	DEFS	1
     18E3	STOP:	DEFS	2
     18E5	SP__:	DEFS	2
     18E7		DEFS	1		; delimiter FF
    
     	PRGBOT:
     			END
    
    IV. Introduction to programming
    4-1. Flow Chart

        A computer executes commands in a precisely logical and sequential fasion. This is how you must learn to think while programming. Imagine how you perform the activity of going to the library to select a book. To borrow a book from the library, you must first travel to the library; but before that you have to leave the house, and before that you make a decision to go, and perhaps collect a load of books for return. In the sentence you have just read, the activities are stated in completely the wrong order. However, you are perfectly capable of sorting them out and executing them correctly. To do this, you use a type of intuition born of long experience. The computer you have just bought is not that intelligent. It must be fed with instructions and presented in precisely the correct order, or it will make a mistake.

        To help in this process, a diagramatic "flow-chart" method will be presented--the visual sense being the most receptive at taking in information. You could break down anything you want your computer to do into small logical steps and arrange them in the correct order. Think of the activity of catching a bus. You know what time the bus is supposed to come, so you make a decision to leave the house at some definite time. When you arrive at the bus stop, you must watch for the bus and put your had out to hail it when it comes. On boarding the bus, you might ask for the price of ride, and then look for the right ammount of money. When you have paid, it is essential to keep your eyes open for the right stop and leave the bus when it comes along. The following flow-chart puts some of these ideas into a diagram for illustration. A few different shapes of boxes are used for different purposes, they are explained below.

        Circles are used to indicate the beginning and end of a process. The circle symbol contains the word start. Sometimes it will contain the name of the process. Rectangles are used for statements where some sort of command is to be executed. The major difference is in the diamond shaped decision boxes. A computer is perfectly capable of making dicisions as to whether something is to be performed or not, and the decision which has to be made is written in a diamond as shown. The process of catching the bus is shown here stage by stage. The first decision which has to be made is whether it is time to leave the house yet. If not, you must wait and keep on checking the time until it is time to leave. This is indicated by a loop on the chart. That is, a closed path which is executed around and around until some condition is met. Here the condition is the time. When the time comes, you walk to the bus stop and enter another looping process while waiting for the bus. The process should be almost self-explanitory from a flow-chart, and in many ways this form is one of the best for explaining new ideas and computer applications to people.

    4-2. Problem with Solutions

        Let us consider the problem of working out one's monthly income after tax. You should have some idea of how the system works already, and it is an easy problem to compute. It also illustrates how you think in a logical manner. The steps are as follows.
     
    (1)

    Imagine what steps you would use to calculate the answer.

    (2)

    Identify the output - i.e. what answer do you want.
    Having done this, the problem is defined.
    Once you have set out the information a-variable (input), and what you expect from the computer (output), you can concentrate on the processing of input data to produce the required output.

    (3)

    Imagine what steps you would use to calculate the answer.

    (4)

    Write down the steps found in (3) in a "flow-chart", or logical sequence.

    (5)

    Convert into computer language.

    (6)

    Type in and RUN the program.

    (7)

    Debug, i.e. correct programming errors, and return until correct.

    (8)

    Store on tape for further use.

        This given information is yearly salary, yearly tax allowance, monthly retirement deduction and tax rate.

        The flow-chart as follows:

        Breaking down the above chart, a flow-chart of the following from is produced.

        We can now write down a program from the last flow-chart which will give a good estimate for most people's monthly wage, given that tax is payable at 30% a year.
     
    (a)

    All lines must start with a line-number. Choose increments of 10 between line-numbers to allow plenty of room for inserting lines into the program wherever you wish.

    (b)

    Each line contains just one statement which must start with a keyword such as PRINT or LET etc.
    Check that you can match each of the boxes in the flow-chart with a statement below.

    
     10 INPUT	A
     20 LET		A1 = A / 12
     30 INPUT	B
     40 LET		B1 = B / 12
     50 INPUT	C
     60 LET		C1 = A1 - B1
     70 LET		C2 = C1 - C
     80 LET		C3 = 3 * C2
     90 LET		D = C3 / 10
    100 LET		E1 = A1 - D
    110 LET		E = E1 - C
    120 PRINT	E
    130 STOP
        Suppose we now wish to run this program, just key in and , the display of the MPF-I will show . Now enter a value for A followed by the key, the program will continue execution until statement 30. At this time you should key in value B, and so on until you have enterd values for A, B and C. The program continues to execute until statement 120 is executed, then the display will show the value E. Press the key and the display will show 130, this means that program exection has stopped at statement 130, pressing again will return you to the BASIC Ready. Now key in , control will return to the MPF-I monitor but the original data stored in the memory is still in there. After pressing reset if you re-enter BASIC by keying in , or for 4K monitor, all of the original statements and variable values will be retained. All variable values and statements are lost if you re-enter BASIC by keying in , or for 4K monitor.

    4-3. Error Codes
     
    E0Expression overflow
    E1Illegal decimal value
    E2Illegal variable name
    E5Illegal relation operator
    E9Syntax error
    EAIllegal value
    ECNEXT without FOR
    EDRET without GOSUB
    EFLine not found

    4-4. Examples
     
    1.

    Use a FOR...NEXT loop to add all the numbers from 1 to a certain number.

    
     10 INPUT	C
     20 LET		A = 0
     30 FOR		B = 1 TO C
     40 LET		A = A + B
     50 NEXT
     60 PRINT	A
     70 STOP
    

        After entering the program key in , and the LED display will show . Now key in the value C and then press the key, the display will show the result. For example, if the value of C is 10 the result will be 55 because 1+2+3+4+5+6+7+8+9+10 = 55. In a FOR...TO statement the initial value, the number or variable between the equals sign and TO, and the limiting value, the number or variable to the right of TO, must be of the same sign.

     
    2.

    Use a FOR...NEXT loop to add all the numbers from one number to another number.

    
      10 INPUT	C
      20 INPUT	D
      30 LET	A = 0
      40 FOR	B = C TO D
      50 LET	A = A + B
      60 NEXT	B
      70 PRINT	A
      80 STOP
    

        C is the initial value and D is ending value. If you want to add from 11 to 15, press and the display will show . Key in to enter 11 for the variable C, then key in to enter 15 for the variable D, the display will show 65.

     
    3.

    In the program below we use the statements GOSUB and RETURN to execute the different subroutines depending on the value C. If the value C is larger than 7, the display will show the sum of numbers from 1 to C. If the value of C is equal to or less than 7 then the product of 1 to C will be computed.

    
      10 LET	A = 0
      20 INPUT	C
      30 IF		C > 7 THEN 70
      40 GOSUB	200
      50 PRINT	A
      60 STOP
      70 GOSUB	100
      80 PRINT	A
      90 STOP
     100 FOR	B = 1 TO C
     110 LET	A = A + B
     120 NEXT	B
     130 RETURN
     200 LET	A = A + 1
     210 FOR	B = 1 TO C
     220 LET	A = A * B
     230 NEXT	B
     240 RETURN
    
    4.

    Using the CALL statement to call the TONE subroutine of the MPF-I monitor.

    
      10 INPUT	C
      20 FOR	A = 1 TO C
      30 CALL	1506
      40 FOR	B = 1 TO 1000
      50 NEXT	B
      60 NEXT	A
      70 STOP
    

        Entering the monitor at hexadecimal address $05E2 will produce a 2KHz tone on the speaker. $05E2 in hexadecimal equals 1506 in decimal. The value entered into C will determine the number of cycles. To obtain a 1KhZ tone enter the monitor at $05DE = 1502 decimal. You may write a program in assembly language to produce sounds of different frequencies and durations. Enter the assembly language shown below.

    
     1800 0E80	LD  C,$80
     1802 21C000	LD  HL,$C0
     1805 C3E405	JP  $05E4
    

    change line 30 in the BASIC program to

    
     30 CALL	6144
    

    Note that 6144 decimal = $1800 hex. Now execute the BASIC program. Use a value of 5 when input is requested.

     
    5.

    The operation of AND, OR, and NOT

    
      10 INPUT	A
      20 INPUT	B
      30 LET	C = A ^ B
      40 PRINT	C
      50 LET	C = A v B
      60 PRINT	C
      70 LET	C = ~C
      80 PRINT	C
      90 STOP
    

        Suppose the input value A is 0, the corresponding hexadecimal value 0, and B is 255, the corresponding hexadecimal value is $FF. After execution, the LED display will show 0. This represents $00 and $FF ANDed together. Now key in and the LED display will show 255. This represents $00 and $FF ORed together. Again key in and the display will show -32512 which represents the NOT of $FF.

     
    6.

    Storing data in RAM

    
      10 INPUT	A
      20 LET	M 6144 = A
      30 LET	B = M 6144
      40 PRINT	B
      50 STOP
    

         The input value can be stored in the position of $1800 and $1801. For example, if the value of A is 13, then $0D is stored in $1800 and $00 is stored in $1801. Thus, the value of B is 13 which equals the value of $1800 and $1801 in the memory.

     
    7.

    Output $55 from port A of the optional PIO, U10

    
      10 LET	P130 = 15
      20 LET	P128 = 85
      30 STOP
    

         The control port address of the PIO channel A is $82, the corresponding decimal value is 130. The PIO channel A is selected as an output port, with the control word of $0F, the corresponding decimal value is 15. And the address of the data port A is $80, the corresponding decimal value is 128. The output data is $55, the corresponding decimal value is 85.

     
    8.

    The division operation

    
      10 INPUT	A
      20 LET	C = A / 3
      30 PRINT	C
      40 STOP
    

         Only integer variables are available in MPF-BASIC. Suppose the input value of A is 11, the resulting value of C after execution is 3, i.e. C is the integer result of A / 3.

     
    9.

    How to check the program stored in the memory. Use example 8 to demonstrate the list actions shown below.

     
    (1)

    Key in , statement 10 will be displayed from right to left (the contents will be shift across the screen).

    (2)

    Key in , the contents of the next statement, statement 20 in this case, will be displayed. Press the key again - now statement 30 will be displayed.

    (3)

    Key in the previous statement will be displayed, 20 in this example.

    (4)

    Key in if you intend to leave the List mode.

    (5)

    Use , , in the List mode, you don't need to press the key.

    (6)

    You just need only to press the key when you want to review the execution in LIST mode.

    (7)

    Just key in directly, if you intend to get the first line of the program in LIST mode.

     
    10.

    This example is to instruct users how to copy the program stored in the RAM buffer to EPROM and how to utilize it. Before copying the program to the EPROM an $FF byte must be added at the beginning and end of the program. Then it is just a case of starting execution from the start of the copied program. We can explain it in the following example.

    The program ..

    
     10 LET		A = 15
     20 PRINT	A
    
    .. is keyed into memory from $1900 onwards ..
    
     18FF	FF		Delimiter
     1900	00	0	Line number first digit
     1901	01	1	Line number second digit
     1902	00	0	Line number third digit
     1903	1F	LET
     1904	0A	A
     1905	18	=
     1906	00	0
     1907	00	0
     1908	00	0
     1909	01	1
     190A	85	5	Bit 7 set to indicate end of statement
     190B	00	0	Line number first digit
     190C	02	2	Line number second digit
     190D	00	0	Line number third digit
     190E	20	PRINT
     190F	8A	A	Bit 7 set to indicate end of statement
     1910	FF		Delimiter
    

        To run the program at this location in memory first re-enter BASIC by keying in , or for 4K monitor, to preserve the RAM contents. Then we type ..

    
           .		6400 decimal = $1900.

        Some versions of BASIC have an error that stops the above from working, for the above to work user should first check whether the value of the memory address $2225, or $0A25 for 4K monitor, is $48 or not. If the contents of this address is $4A, the user ought to use the EPB-MPF or another method to change the value to $48.

    The image of U6 from my MPF-1B has had this byte corrected to $48.


    Last page update: 8th May, 2005. e-mail me