BASIC-hlPF

OPERATION
MANUAL

COPYRIGHT Copvnqht © 1983 by Multitech Industrial Corp All fights reserved, No part of this publication may be reproduced, transmitted, transcribed, stored in a retrieval system; or translated into any language or computer language, in any form or by any means, electronic, mechanicai, magnetic,. optical, chemical, manual or otherwise, without the prior written permission of Multiter:h Industrial Corp.

DISCLAIMER Muiri tech Industria I Corp. makes no representations or warranties, either ex press implied, with respect to the contents hereof and specifically disclaims any warranties or merchantability or fitness for any particular purpose. Multitech Industrial Corp. software described in this manual is sold or licensed "as is" Should the programs prove defective following' their purchase, the buyer (and not Mu Ititech Industria I Corp., its distribu tor, or its dealer) assumes the entir e cost of all necessary servicing, repair, and any incidental or consequential damages resulting from any defect in the software. Further, Multitech Industrial Corp. reserves the right 10 revise this publication and 10 make changes from time to time in the content hereof without obligation of Multitech Industrial Corp 10 notify any person of such revision or Changes.
01

JMultitech
INDUSTRIAL CORP
OFFICEj 15FL. 135 CHIEN KUO N. ROAD, SEC, 2. TAIPE' , 0479. TAIWAN, R.O.C. TEL: 1021505.5533 TELEX: 19162 MULTIIC FACTO.RYI 1 INDUSTRYE. HSINCHU HSINCHU, ROAD. III. INDUSTRIAL PARK 300. R.O,C, SCIENCE·BASED TAIWAN FAX: (021505-4451

I .Introduction
BASIC is the most popular high level computer language used by many of today's computers. BASIC stands for Beginners All-purpose Symbolic Instruction Code. However, it should not be assumed that the BASIC language is only used for beginners, and has no application in the "outside 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 i~ 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 powerful expansion capabilities has been developed by Multitech Industrial Corp. to execute the instruction of Z-80 and 8085 microprocessors. To help the Micro-Professor user to learn BASIC programming, Multitech presents the MicroProfessor BASIC Interpreter.

-5-

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 overlays nal MPF-I keyboard. the origi-

(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 cassette tape. SAVE - Save a program on the cassette 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.

-6-

(5) Var Lab les Ca) (b) (c) Numeric Variables are the only type used in MPF-l BASIC. Variables can only hold "integer: II or whole number values such as 235 or -3451. Limit: the limit for MPF-l BASIC is from -32767 to 32767. (But error massage will be occurred if one or both of the numbers to be multiplied are negative.) Variables Name: The length is one or two characters. If the length is one character, it must be any of A~F. If the length is 2 characters , the first must be any of alphanumeric letter A-F, the se~ond must be any of

(d)

numeric digit 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.J LET Variable = P decimal Assign variable with the contents of the specified I/O port.

7

(THIS PAGE HAS BEEN INTENTIONALLY

LEFT BLANK)

II.MPF-I BASIC Interoreter
This chapter must be read. very carefully, including how to install BASIC Interpreter, to make use of keyboard and display, to edit program, and 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 EPR.OM ei ther a TMS2516 or an Intel 2716. Another model is the MPF-I monitor with built-in BASIC Interpreter (MPF-IB) on a 4K byte IC storing in TMS2532. There is a spare IC location for memory expansion, marked by U7 in MPF-I. -The address range of U7 is from 2000H to 27FFH (refer to the diagram below). Before inserting this EPROM in the socket at U7, insure that the index mark 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 Dot properly aligned •

.. •
0

n c:

..

...
!
D C

n


e

..

.. , •
0

U6

.

(J

• ..• ..UF

<> c:

...
~

N'"

! ..
'0

'",.

ot
"

..

[:1:

~

..
0
n n

c

• •
e

.. a ..

..

.. •
0

;)

..

Cio
.

-"

0

:t ..

n n

.. • ..

~t

~

• ..
~~..
,~~

,. ..
N

,'-'

.. '"

..

.. '"

;;

"

s

UI3 I

T!J
..
;

ill

UI'

-9-

Overlay the MPF-I keyboard with the BASIC name plate. Next key in fGOTOI III [QJ [QJ [QJ I RUNI , bu t key in IGOTol []ll (J[J I RUN I i fuse rs operate a 4K bfte monitor. The LED display will show IbASIC., 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 BASIC Interpreter.

rn [[]

2.2 Keyboard Use and Display
MUlTITECH
BASIC·MPF
D(I/.;Cl~q

DD0
D D D
SHIFT

Run

D
~/A

,0*/9

0
D D
GOTO PlEW

Tola

W
[]] •• [I]
'"

NEXT

~~:NT

IH~VT

[QJ
IT] IT] [Q
~

IT]
e..u,

m
no.

ltT

DDD D0
SAW
COIiIT

GOSUI

NT/_

n<,It/¥

D D
lI"'II.

UIT

-

mm
m
<

IT] IT]
I

>

0

LOA,ll

0

~U"

D

m
+

-

w

The diagram above is the special Name Plate for MPF-I BASIC. There are 34 ~eysJ but some keys have two different meanings. We can divide these 34 keys into'the following groups: (1) RESET Key: RESET MPF-I and return to the control of MPF-I monitor. (2) SHIFT Key: To select cursor addressing key and operator key. (3) Alphabetic Keys: A-F (4) Numeric Keys: 0-9 (5) Operator Keys: +, -j *J I, **. =, <, >, ......... J\ (AND). V (OR). _These keys are (NOT), used with SHIFT key. (6) Cursor Addressing Key: ---,--, are used with SHIFT key. (7) Command Keys: SAVE, CONT, LIST, LOAD, RUN, ENTER, NEW.

t't'

- 10-

Statement Keys: IF, THEN, GOSUB, RET, FOR, TO, NEXT, GOTO, LET, PRINT, INPUT, CALL, STOP. (9) Delete Keys: DEL, used to delete the letter or keyboard at the Cursor. CLR, used to delete the full line just entered . . (10) Special Variable Keys: M and P used with SHIFT key
(8)

The keyword concept is utilized 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. When the MPF-I is under the control of the BASIC Interpreter, the LED display will show IbASIC.I. After the IGOTOI key is pressed, the LED display will show Dc Got.1 . When I DELI is pressed, the LED display will show I bAS IC. t • The 19 keywords ~ill constitute the majority of the "sentences" written in your computer programs, and each sentence will begin on a new line, with a unique line number to identify it. Try to type 10 PRINT The first number "t eri'", [AJ (ENTERI. follows: A two characters "10" are the line The order of keys are [Q] 1r-=P=R""""IC7"'N=T""""1 The corresponding display will show as

m

LED Display Before Key in Key Key Key Key in in in
in

any key is pressed

I bASIC . I
IASIC

IT1
[QJ

1.1

ISIC 10. I

I PRINT I
IT)

I

lO2rt.!

IIO}2rtA .1

I ENTER I
- 11 -

I bASIC . I

During the, statement checked. Try typing

entry, the syntax will be

5 LET

A=l

The word syntax is used in programming and relates to the order of your keyboard entries. In English syntax means the pattern of sentences and phrases that are constructed from words. In BASIC the syntax is checked to see if you constructed each BASIC statement correctly. The MPF-I BASIC checks for syntax in two ways~ First preliminary checking is done as each part of • BASIC statement is entered. Secondly after the rENTERI key is pressed, the entire line is checked for correct syn tax. If the []] key is pressed instead of the key, the di spIay .wi 11 show I E2 .1 after I ENTERI key is entered (2 is the Error Code). By means of pressing 1---1 , I DELI, and 1I keys, the statement can be corrected as shown belOW. Display

rn

IE2
Key in Key in Key in Key in Key in Key in Key in Key in Key in

.I
(1.

I-I I-I I-I I-I
I-I

I

J

I

00.' 005·1

I005LEt.J I05LEt2.1 I05LEt=·1

IDELI
J~I

I 005LEt·1
I05LEtA·1 1 - 12 -

m
I ENTER

I bASIC .I

There is now a program 5 LET A=l
10 PRINT A

stored in the program memory

we want to execute and ,I ENTERI. Bu t ;. IRUN] [5] En] I ENTERI when we 50 line number of the statement first line. The corresponding

Suppose press I RUNI

this program, we should we just need to pr ess inte~d to run from the not to go back to the display is shown below. LED Display

Before key is pressed Key in Key in Key in

I bASIC .1
Ie run .1
000011 bASIC

I RUN I
I ENTER I

I CONT I

.J

Following

is the key processing on

and display format.

CISPLAY FORMAT
DISPLAY KEY DISPLAY KEY DISPLAY KEY DISPLAY KEY OISPLAY KEY DISPl~Y FOAMAT TO

MPF-i
BASIC LET I I' - MPF PAINT INPUT NEXT GOSUB A E T GOTO fI Inc MUlTITECH

ON

THEN

1:0 I:hn Lee rrt: InF nee Uu:l ,-cc
,-,I

II

I _,-

r-I

I-err

,-

FOR

IF 0-

,-

CALL

Lnl

,-ru

STOP

RUN

LIST II, 2

SAVE

LOAD

I I Cl :0- run L:IC
0 1 (j C

CDI _~
:J
F

LD
4

,,
L1
....
P

U

,

I

['
E

-,

3

,

5

6

.J

D
v
,I

L

.,,
7

8

9

A

B

'-

r

=

, , ,- -, " r D
D

+

C

I,

I,

U

-,,

n u

-

u I

n
I

,I

n

J

1-

*

,-, ,

**
I

<

>

M

-

-

L

_I

rr

(I I

- 13-

The followi ng conceptions should be thoughtfully noted when users operate the BASIC Interpreter. 1. After users overlay the MPF-I keyboard with the BASIC name plate and key in IGOTOI] [~] [Q] [[] [Q] IRUN I (0800 for 4K moni tor), the BAS Ie Interpreter will clear the RAM buffer(1800H-lFADH i.e. set the contents of RAM buffer to be zero. Secondly. set the value of memory address 18E7 to be FF as the de11meter. Thus, if users set the starting address to be 2017 (0817 for 4K moni tor) and press [RJI[] key. the contents of user I s program in MPF-I would not be destroyed .. 2. The storage areas of userls program begins at the memory address - 18E88 and terminates by a delimeter - FF. For e~ample, if users key in two statements as follows. 010 020
LET

PRINT A5

A5 = 180

The BASIC Interpreter will accept the keyword and c6nvert the keyword into the corresponding BASIC internal code (as to the corresponding BASIC internal code, please refer to the page 24). The below instructions occupy 18 bytes of memeory.

- 14-

18E7 18E8 18E9 18EA 18ES 18EC 18ED 18EE
18EF 18FO 18F1 18F2

FF
'00 00

01 IF 18

OA 05 00 00 01 08 80 00

18F4 18F502 l8F6 00 18F7 20 l8F8 OA 18F9 85 18FA FF

18F3

The BASIC Interpreter sets Bit 7 of the last byte of each statements as the delimeter with a view to distinguish from another statements. From the above example, we know that l8F3 00 will be shown as this statement had been terminated, but 18F3 80 will be displayed when this statement will be went on with other statements. 3. The stack pointer of the BASIC-MPF is IF9FH because the USERSTK of MPF-I is lF9FH. Thus, if the user's programs are so large that in excess of the memory address - IF9FH, the programs storing in the BASIC Interpreter will be disordered.

- 15-

2.3 Program Edit Be f'o -e edi ting program, we can check any sta tament r by LIST command. For example, i.f we want to check

10 of the above program, pressing 'LISTI I ENTER I. The· LED display will show state10 from right to left. And then th.e display will show I A • I. We leave LIST mode 1)~ pressi ng I ENTE!U key, LED display will show IbASIC ~ to indicate that BASIC is ready. As the data on the display is being shifted from right to left pressing any key (except RESET) will stop the shifting. Shifting may be resumed by pressing any key (except RElET)., By repeated key presses (for example the .LIST key) you may start and stop the shifting action of a display several times. Because each BASIC statement has a unique line number to identity it, we edit the request statement by replacing 1t with a new statement. For examp le , if we want to change s tat emen t 10 to

m ment

statement

[QJ

10 LET C

=

A

tENTER. After IENTE:RI key is pressed, the ment 10 PRINT A will be removed from program. and 10 LET C = A will be stored into it. The program stored in program memory now becomes 5 LET A = 1 10 LET C = A

The kers we shou ld pr eas are

[JJ[Q] [LETI

r:g I =]

rn state-

- 16-

If we want to Ln ser t a sta tement 7 PRINT .A between statement 5 and 10, we can press fo110wi ng keys: [I] I PRINT I rENTER I. After the i ENTERI key is pressed, the statement 10 LET C = A will move backword from the original memory location to leave space for statement 7 PRINT A. Statement 7 will be inserted between statement 5 and statement 10. Now the program stored In the program memory becomes

rn

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

from the program its line number and then I ENTER! key. For example, we want to delete statement 10 from, the above program, press ·the keys as follow:

memQry by pressing

We can delete any statement

rn [[] r ENTER I
Now the program stored in program memory is
5 LET A = 1 7 PRINT A

- 17-

2.4 Cassette Storage (1) Saving Program onto Tape We can save the program in the memory on the tape by pressing I SAVEl <filename> IENTERJ. Where: (a) Filename is a decimal number from 0 to 255 and. (b) Before pressing IENTERI, you must connect the microphone of the recorder to MIC jack of MPF-I and press PLAY and REC to start recording. The display is blank during transfer, the TONE-OUT is on and the tone sounds. After recording, the display will showlbASIC .1.
LED

(2)

loading Program from Type We can load the program from type into memory by pressing IIOADI <filename> IENTERI. Where: (a) Filename is a decimal number from 0 to 255 and. (b) Turn the volume of recorder to Maximum. (c) Press IENTERI, and finally start the recorder by pressing PLAY.

- 18-

At the beginning, the display is I When the requested file is found, the display becomes 1- - - - - -I. 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 characters (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 checksum from the tape, an error has occured and the display wi 11 show I -Err I. Control wi 11 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.

1.

2.5 Immediate Instruction
A statement entered without a statement number will executed immediately afte~ the I ENTER I key is pressed. "Immediatell instructions allow you to use the MicroProfessor as a calculator. The procedure to compute 3 x 8 is shown below.

IPRINT I

m QJ ill I

EN'TERI To return to

The display will show 1000241. press ICONT).

I bASIC .1

19 -

c. The storage area of user's program begins at the memory address - 18E8H and terminates by a delimeter-FF. For example, if users key in only bne instruction as follows. 010 LET A5

=

180

The BASIC Interpreter will accept the keyword and convert the keyword into the corresponding BASIC internal code. The above instruction occupies 12 bytes of memory. Please 'refer to the Page 15 of BASIC-MPF OPERAT ION MANUAL. 18E7 18E8 18E9 18EA 18EB 18EC 18ED 18EE 18EF 18FO 18Fl 18F2
l8F3 18F4 18F5

FF 00 01 00 IF OA

18 00 01 08

05

00

80 FF XX

The BASIC Interperter sets Bit 7 of the last byte of each statement as the delim~ter wit~ a view to distinguish from another statements. From the above example, we know that l8F3 80 will be displayed when this statement is going on with another statements. d. The stack pointer of the BASIC Interpreter is IF9FH because the USERSTK of MPF-! is IF9FH. Thus, if the user's programs are so large that in excess of the memory address - 1F9FH, the programs storing in the BASIC Interpreter and the MPF-I monitor will be disordered.

- 20

-

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 -32761 to 32767. Cd) Variable Name: The length is one or two characters. If the length is one charactert it must be any of alphabetic letter A-F. If the length is 2 characters, the first must be an alphabetic letter A-F. The second must be anyone of the numeric digits 0-9.

3-2. Operators Symbol
=

Function Assignment or equality test Negation or Subtraction Addition Multiplication Division (Integer) Raising to a power Equa 1 Less than Gr.ea ter than lIS Complement Bitwise AND Bitwise OR

* / ** =
,.._,
A V

+

>

<

(NOT) (AND) (OR)

- 21-

3-3, MPF BASIC Symax Gramtnllr

Tsble

* * MPF BASIC Syntax Grammar Table * *****************************************************************
-

*****************************************************************

* *
*

digit letter

: := 0111 AIBI
r= ,_

•••

19

•••

IF
I

oper ator: unary

1A I V 1 + I -

*

I/

I

**

":::: + I -

I"..._.
I

relation::= decimal

> I=

<
I+

:::::: <digit> ( Range

<digit)

I-

<digit>

I

<decimal> )

<digit)

: -32767 to +32767 inculsivly

filename::=

<decimal) : 0 to 255 inclusivly
1)

( Range

)

portaddr: :::z: <decima ( Range: variable::= memory port lineN

0 to 255 inclusivly 1 <letter>

)

<letter>
Irf

<digit>

<deci rna 1>

P (portaddr> :::::: <digi t > ( Range <lineN> <digi t>

: 1 to 3 digit )

- 22-

value

..= <decimal>
I

I

<variable>
I

VMP val ::= <value>
VMP

<memory>

<port>

var ::= <variable> I <memory> I <port> express": [unary] <value> [unary] <value> <operator> [unary) <value>

VMP_exp

: .= (unary] <VMP val>
(unary] <VMP val>

I

[unary] <VMP val> <operator>

***

CLA(JSE

***
· .= · .= · .=

LET clause PRINT clause

[<lineN>1 LET <VMP var> = <VMP exp> [<line#~l PRINT <VMP exp> [<lineN»~ INPUT <variable> [<Unell>] NEXT <v-ariable> [< n ne#> ] GOSUB <lineN> [<11ne#>] RET [<line#> ] GOTO <line#> [<line#>] FOR <variable>
=

_

-

_

INPUT clause
N;EXT

clause

· -=
: :=

GOSUB clause RETURN .L.c lause . GOTO clause FOR clause IF clause CALL clause STOP clause

· ·

.:::;:

.;:

::=

<value> TO <value> <VMP exp>

::: [<lineN>] IF <VMP_exp> <relation> THEN < Ii nelt> ::= [<line#>] CALL <decimal>
· '=

[<11ne#>] STOP

- 23 _

*** COMMAND ***
RUN

command

"": RUN

[<line#>]

LIST command

- LIST [ <line,.¥>]

SAVE command
LOAD command
NEW

... = SAVE (filename>
: :=

LOAD

(filename>

command command:

... =

NEW

CONTINUE

:= CONT DEL
::= CLR

DELETE command
CLEAR comma.,nd

***********************************************************'****** * Internal MPF BASIC Code Table * * *****************************************************************
Code 00 01 02 03 04 05 06 07 08 09 OA DB DC 00
O.E Of'

* * *

Mean
0
2

( hex)

1

3 4 6 7 8
9 A 5

B

Code (hex) 10 11 12 13 14 15 16 17 18 19 lA

Mean
NOT OR
+

AND


** = (
M

/

Code (hex) 20 21 22 23 24 25 26 27 28
29

Mean

PRINT INPUT NEXT GOSUB
RET

C
D
E

IB Ie IF
IE

>

2A
2B

GOTO FOR IF CALL STOP
run

Code (hex) 30 31 32 33 34 35
36

Mean

delete clear enter (left) (rlght)
(down)
(UP)

p

10

TO

THEN

F

LET

2C 2D 2E 2F

cant

list save load Dew

- 24-

3.4 System RAM Areas of BASIC-MPF

1800 1800
l8CC

ORG

1800H 2* (6*10H+6)
1

VARBUF: DEFS DEFS L INBUF: DEFS FLAG: STOP: SP DEFS DEFS DEFS DEFS PRGBOT:
END

;variables

buffer

18CD 18E2
l8E3

21
1 2

;line buffer

18E5 18E7

2
1

;delimeter

FF

- 25-

(THIS PAGE HAS BEEN INTENTIONALLY

LEFT BLANK)

N.Introduction to programming
4-1. Flow O1art A computer executes commands in a precisely logical and sequential fashion. 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 wi th instructions and presented in precisely the correct order, or it will make a mistake. To help in this process, a diagrammatic "flowchart" 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 hand out to hail it when it comes. On boarding the bus, you mtght ask for the price of ride, and then look for the right amount 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 illustra tion. A', few di fferen t shapes of boxe s are used for different purposes, they are explained below.

- 27-

TAKE OUT SOME MONEY

NO LEAVE HOUSE

WALK

TO BUS

STOP

WATCH FOR

OUT STOP

WATCH

FOR

BUS NO

NO

HAIL

AND

STOP

BUS

- 28-

Circles are used to indicate the beginning and end of a process. The symbol a circle 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 different is in the diamond shaped "decision" boxes. A computer is perfectly capable of making decisions 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 1I100p" on the chart. That is, a closed path which is executed around and around until some condition is met. Here the condition is t he 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-explanatory from a flow-chart, and in many ways this form is one of the best for explaining new ideas to people including more computer applica tions.
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) Indentify the output - i.e. what answer do you want. Having done this, the problem is defined. Once you have set out the information available (input), and what you expect from the computer (output). you can concentrate on the processing of input data to produce the required output. - 29-

(3) Imagine what steps-you would use to calculate the answer. (4) Write down the steps found in (3) in a '''flow-chart'',r logical sequence. o (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 future use. This given information is yearly salary, yearly tax allowance, monthly retirement deduction and tax rate. The flow-chart as follows:

BOX A

Work out monthly Wage (Al) and tax allowance

BOX

8

t
Work out total tax paid Reduce Al by total tax: paid and s upe rpos ition

BOX C

+

BOX

D

I

Print

+

answer

I

- 30-

Breaking down the above chart, a flow-chart following from is produced.
INPUT yearly wage (A) ~his takes wange from

of the

yearly keyboard

this equivalent to BOX A

finds

monthly

wage

INPUT yearly tax allowance (B)

this takes yearly tax allowance from keyboard this finds monthly tax allowance

INPUT replaces BOX B

reti'fement deduction (C)
per month

LET D=O.3x(AI-BI-C)

BOX

C

LET E=AI-D-C

BOX D

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% per year. (a) All lines must start a line-number. Choose incremens of 10 between line-numbers, to allow plenty of room for inserting lines into 'the program wherever you wish.

31-

(b) Each line contains just one "statement" which must scae.t 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 Statement 10 20 30 40 50 60 70 80 90 100 110 12D 130 INPUT LET INPUT LET INPUT LET LET LET LET LET LET PRINT
STOP

below A Al = A/12 B Bl = B/12
C

Cl=Al-Bl G2 = Cl - C C3 = 3*C2 0 = C3 / 10 El = Al D E = El - C

-

E

Suppose we run this profram after its entering, just key in I RUN I and I ENTER_. The display of MPF-I will show 11 n p.l. After you enter value A and followed by IENTER I, the program will continue execution until statement 30. At this time you should key in value B, and so on until you enter all A, B, C values. The program continues to execute. After statement 120 is executed, the display will show the value E. Press I CONTI key and the display will show 130 • This means that rrogram execution stops at statement 130, p~~ss rCONT_ to return to BASIC READY. Now key in IRESET), the statement will return to the MPF-I monitor but the original data stored in the memory is still in ther. e. After pressi Il£__!es:et you enter BAS Ie...l!l if keying in IGOTOI tai LQJ OJ I RUNI (I GOTOI LQJ [HJ []J [J[] (RUN' for 4K m~nitor), all of original statements and values represent by the variables will be retained. All variables and statements are lost if you enter BASIC by key in (GOTOI ~ []O[QJ [Q] IRONI(0800 for 4K monitor).

m

- 32-

4-3. Error Codes

EO El E2 E5 E9 EA EC ED

EF

Expression Overf'low Illegal decimal Value Illegal Variable Name Illegal Relation Operator Syntax Error Illegal Value FOR •••..• NEXT Not Compatible GOSUB ••••••RET Not Compatible Line Not Found

- 33-

4-4. Examples 1. Use FOR •••NEXT loop to add from 1 to a certain ·number. 10 20 30 40 50 60 70 INPUT LET FOR LET NEXT PRINT STOP C A=0 B = 1 TO C A =-A + B
B

A

[Description]: After executing the statement, key in IRUNI IENTERI t and the LED display will ishow IInp .1. At this moment, key in the value_d and then key in I ENTER I, the display will show the result. For example, the result will be 55 when the value C is 10 (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. Account 10 20 30 40 50 60 70 80 INPUT INPUT LET FOR LET NEXT PRINT STOP the series digits amount
C

D

A
B

A A

B

= = =

0 C TO A+B

0

[Description]: C is the initial value and D is ending value. If you want to add from 11 to 15, press IRUNI , IENTERI the display will show I INP.I key in an 11 for tbe variable C. Key in the value 15 and press IENTERI, the display will show 65.

J

- 34-

3. In the program below we can use the statement "GOSUB ....RETURN" to execute the different subroutines depending on the value C. If the value C is larger than 7, the display will show "1+ .. ••+C". When C is equal to or less than 7 then l+ .••+C-will be computed.

10 20 30 40 50 60 70 80 90 100 110 120 130 200 210 220 230 240

LET A=0 INPUT C IF C > 7 THEN 200 GOSUB PRINT A STOP GOSUB 100 A PRINT STOP FOR B=1 LET A=A NEXT B RETURN LET A=A FOR B= 1 LET A=A NEXT B RETURN

70

TO C +B +1 TO C

*

B

4. Apply the CALL statement subroutine of MPF-I. 10 20 30 40 50 60 70 INPUT FOR CALL FOR NEXT NEXT STOP C
A

to call the "TONE"

B A

1508 B=1

=

1

TO TO

C 1000

[Description]: Entering the monitor at hexadecimal address 05E2 will produce a 2KhZ tone on the speaker. 05E2 in hexadecimal equals 1506 in decimal. 05E2 (BASE 16) = 1506 (BASE). The value entered into C will determine the number of sound intervals. To

- 35-

obtain a 1KhZ tone enter the monitor at 05DE (BASE 16) = 1502 (BASE 10). You may write a program in assembly language to produce sounds of different frequencies and duration. Enter the assembly language shown below. 1800 OE80 1802 21COOO 1805 C3E405 change LO LO JP C, 80H HL,OCOH 05E4H

line 30 in the BASIC program to 6144

30 CALL

note 6144 (BASE 10) = 1800 (BASE 16). Now ex,cute the BASIC program. Use a value of 5 when lnpdt is requested.

5. The operations 10 20 30 40 50 60 80 INPUT INPUT LET PRINT LET PRINT LET PRINT STOP
A

of AND, OR, and NOT

B
C

70

C = AV B C C = .....,c

C

=

AAB

90

C

[Description"]: Suppose the input value A is 0 (the corresponding hexadeci.mal value 0), and 8 is 255 (the corresponding hexadecimal value is FF). After execution, the LED display will show O. This representd OOH and OFFH ANOed together. After key in ICONT I , the LED display will show 255. This represents OOH and OFFH ORed together. Again key in ICONTI, the display will show -32512 which represents the NOT of OFFH.

- 36-

6. Storing data in RAM 10 20 30 50 IN,PUT LET A M 6144 = A B = M 6144
B

40

LET

PRINT STOP

[Description]: The input value can be stored in the position of 1800H and 1801H. For example, if the value of A is 13, then DOH is stored in 1800H and DOH is stored in 1801H. Thus, the value of B is 13 which equals the value of 1801H and 1800H in the memory.

7. Output 055H from the port A of PIO
10 20 30

LET
LET

STOP

P130 = 15 P128 = 85

[Description]: The control port position of MPF-l channel A is 82H. (The corresponding decimal value is 130.) The PIO channel A is selected to be the output port, so its control word is OFR. (The corresponding decimal value is 15.) And the position of data port A is 80H. (The corresponding decimal value is 128.) The output data is 55H (the corresponding decimal value is 15). 8. The divi sion 10 20 INPUT LET PRINT STOP operation A C C

30 40

= A/3

[Description]: BASIC variable in the MPF-I are only integers. Suppose the input A is 11, the value C is 3 after executing i.e. C is a quotient.

- 31-

9. How to check the program

stored in the memory.

Use example 8 to demonstrate the list actions shown below. ..... I rENTERl, statement 10 (1) Key in r-I L-I-S-T will be displayed from right to left (the contents will be shift across the screen). (2 ) Key in CD , the contents of the next sta tement (statement 20 in this case) will be displayed. Press the[J[J key again - now statement 30 will be displayed. (3) Key ioCI] the previous statement will be displaY~io this example). (4) Key in ~ if you intend to leave the List mode. (5) Use [I] ,1"---:.----"1, I -I in the List mode, you don't need to press the SHIFT Key. --'I key (6) You just need only to press therl~ when you want to review the execution in LIST mode. (7) Just key in IlISTI [ENTERI directly, if you intend to get the first line of the progam in LIST mode.

rn []]

- 38-

10. This example is to instruct users how to write the program·storing in RAM buffer to EPROM and how to utilize it. Before the users store the program in the EPROM, having to add a !IFF" at the beginning a-nd ending of this program. Thus, it is just needed to run the beginning of this program as the execution on the BASIC Interpreter. We can explain it from the following example. 010 020 Key in LET A = 15 PRINT A 18FF 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 190A 1908 190C 1900 190E 190F 1910 M 6400 FF 00 01 00 IF OA 18 00 00 00 01 85 00 02 00 20 SA =1900
(6 )

FF

I RUNI

IENTE'R)-'.(640010

[Description]: The users first have to check whether the value of the memory address 2225 or OA25 (for 4K monitor) is 48H or not. As the cont~nts of this memory is 4AH, the user ought to use the EPB-MPF or another method to change the value to be 48H.

- 39-

AA "\:J

hlultitec'h
INDUSTRIAL CORP.

--

--

-

--

Sign up to vote on this title
UsefulNot useful