Sharp MZ-700 Series Owner's Manual

Personal Computer
im-7/m
OWNER'S MANUAL
SHARP
IMPORTANT
The wires in this mains lead are coloured in accordance with the following code:
BLUE: Neutral BROWN: Live
As the colours of the wires in the mains lead of this apparatus may not correspond with the coloured markings identifying the terminals in your plug proceed as follows. The wire which is coloured BLUE must be connected to the terminal which is marked with the letter N or coloured black. The wire which is coloured BROWN must be connected to the ter- minal which is marked with the letter L or coloured red.
This apparatus complies with requirements of EEC directive 76/889/EEC.
Das Gerat stimmt mit den Bedingungen der EG-Richtlinien 76/889/EWG iiberein.
Cet appareil repond aux specifications de la directive CCE 76/889/CCE.
Dit apparaat voldoet aan de vereisten van EEG-reglementen 76/889/EEG.
Apparatet opfylder kravene i EF direktivet 76/889/EF.
Quest'apparecchio e stato prodotto in conformita alle direttive CEE 76/889/CEE.
Personal Computer
mz-Tffixo)
Owner's
Manual
© SHARP CORPORATION
NOTICE
This manual has been written for the MZ-700 series personal computers and the
> BASIC interpreter which is provided with the MZ-700.
* iwXliffY * m M m ii
| (1) All system software for the MZ-700 series computers is supported in software
packs (cassette tape, etc.) in file form. The contents of all system software and the material presented in this manual are subject to change without prior notice
i for the purpose of product improvement and other reasons, and care should be
taken to confirm that the file version number of the system software used matches
T .
* -
I $ (2) All system software for the Sharp MZ-700 series personal computer has been
f Reproduction of the system software or the contents of this book is prohibited.
t
*
4 | (3) This computer and the contents of this manual have been fully checked for
T i ed by reading this manual, please do not hesitate to contact your Sharp dealer
V $ a result of operation or use of this equipment.
that specified in this manual.
developed by the Sharp Corporation, and all rights to such software are reserved.
completeness and correctness prior to shipment; however, if you should encoun- ter any problems during operation or have any questions which cannot be resolv-
for assistance. Not withstanding the foregoing, note that the Sharp Corporation and its repre- sentatives will not assume responsibility for any losses or damages incurred as
Preface
Congratulations on your purchase of a Sharp MZ-700 series personal computer. Before using
your computer, please read and make sure you understand the operating procedures which are described in this manual. The features and general operating procedures are described in
Chapters 1 and 3, so please read those chapters first.
All software for the MZ-700 series computers is distributed on cassette tape. The cassette tape included with the computer contains BASIC 1Z-013B, a high level BASIC
interpreter which enables programming in the BASIC language and makes it possible to utilize the full capabilities of the MZ-700. The BASIC 1Z-013B interpreter and procedures for its use are fully described in this manual.
MZ-700 OWNER S MANUAL
CONTENTS
Chapter 1 The world of MZ-700 Series Personal Computer
1. 1 Features of the MZ-700 Series 10
1. 2 Using this Manual 12
1.3 An Introduction to the World of Computers 13
Chapter 2 BASIC
2. 1 Introduction to Programming in BASIC 16
2. 2 An Outline of BASIC 21
2. 3 Frequently Used BASIC Commands and Statements 28
2. 4 Built-in Function 71
2. 5 String Function 76
2. 6 Color display state ment 80
2. 7 Color Plotter-Printer Commands 82
2. 8 Machine Language Program Control Statements 91
2. 9 I/O Statements 95
2. 10 Other Statements 96
2. 11 Monitor Function 99
Chapter 3 Operating the MZ-700
3. 1 Appearance of the MZ-700 Series Personal Computers 104
3. 2 Connection to Display Unit 106
3. 3 Data Recorder 108
3. 4 Color Plotter-Printer 110
3. 5 Key Operation 114
Chapter 4 Hardware
4. 1 MZ-700 System Diagram 122
4. 2 Memory configuration 123
4. 3 Memory Mapped I/O ($E000-$E008) 130
4. 4 Signal System of Color V-RAM 133
4. 5 MZ-700 Circuit Diagrams 134
Chapter 5 Monitor Commands and Subroutines
5. 1 Monitor Commands 146
5. 2 Functions and Use of Monitor Commands 147
5. 3 Monitor Subroutines 151
APPENDICES
A. 1 Code Tables 154 A. 2 MZ-700 Series Computer Specifications 157 A. 3 BASIC Error Message List 159 A. 4 Z80A Instruction Set 160 A. 5 Monitor Program Assembly List 164 A. 6 Color Plotter-Printer Control Codes 198 A. 7 Notes Concerning Operation 201
INDEX
[BASIC COMMANDS] ( ) is abbreviated format
® ABS
ASC 78 ATN 71 AUTO (A.) 31 AXIS (AX.) 89
® BYE .
CHR$ 78 CIRCLE (CI.) 90 CLOSE (CLO.) 68 CLR 59 COLOR (COL.) 80
CONSOLE (CONS.) .... 98
CONT (C.) 34 COS 71
CURSOR (CU.) .... 61
(B.) .... 35
71
®
HSET (H.) .... 88
s
IFERL 97 IFERN 96 IF-GOSUB (IF-GOS.) 53 IF-GOTO (IF—G.) 53
IF-THEN (IF—TH.) .... 50
INP 95 INPUT (I.) 42 INPUT/T (I./T) 68 INT 71
0
KEY LIST (K. L.)
35
®
DEFFN 56 DEF KEY 57
DELETE (D.) .... 31
DIM 56
END
EXP .
(E.)
59 71
LEFTS LEN 76 LET 36 LIMIT (LIM.) 92
LINE 85
LIST (L.) .... 32
LIST/P (L. /P) .... 84
LN 71
LOAD (LO.) .... 28
LOG 71
FOR-NEXT
GET GOSUB
-RETURN (GOS.-RET.) GOTO (G.) GPRINT (GP.)
(F. ~N.)
47
43
49 48
88
MERGE (ME.) MID$ MODE GR (M. GR) MODE TL (M. TL) MODE TN (M. TN) MODE TS (M. TS) MOVE MUSIC (MU.)
77
32 77 83 83 83 83 87 65
®
NEW 32
®
ON ERROR
GOTO (ON ERR. G.) . . . . 96
ON~GOSUB (ON-GOS.) .... 55
ON-GOTO (ON~G.) .... 54
OUT 95
®
SAVE (SA.) 29 SET 63
SGN 71 SIN 71 SIZE 97 SKIP 84 SPC 62 SQR 71 STOP (S.) 59 STR$ 79
®
PAGE 84 PAI 71
PCOLOR (PC.) .... 83
PEEK 93 PHOME (PH.) 87
PLOT OFF (PL. OFF) .... 98
PLOT ON (PL. ON) ... . 98
POKE 92 PRINT (?)••• 37
PRINT USING (?USI.) .... 38
PRINT/P (?/P) .... 84
PRINT/T (?/T) .... 68
PRINT [a,/3] (? [a,0]) 81
©
TAB 62 TAN 71 TEMPO (TEM.) 67
TEST (TE.) .... 84
TI$ 60
©
USR (U.) 93
®
VAL 79
VERIFY (V.) 30
©
®
®
RAD 71
READ-DATA (REA. ~DA.) .... 44
REM 58
RENUM (REN.) .... 33
RESET 63 RESTORE (RES.) 46 RESUME (RESU.) 97 RIGHTS 77
RLINE (RL.) .... 86
RMOVE (RM.) .... 87
RND 72
ROPEN (RO.) .... 68
RUN (R.) .... 34
WOPEN (W.) .... 68
® ®
®
3VA2
. zn
P.)
TT
{.A1 - ;v
......
. . i .
......
a/. 3
..
-
THE WORLD OF MZ-700
SERIES PERSONAL
COMPUTER
Chapter 1
1.1 Features of the MZ-700 Series
In the space of just a few decades, the computer has undergone a dramatic transformation, changing from an intricate, enormously expensive monster weighing several dozen tons into a compact, inexpensive device which can be used by almost anyone. Whereas access to computers used to be limited to a few privileged individuals with special training, the inexpensive, user-friendly machines now available make the world of computing open to people in all different walks of life. The Sharp MZ-700 series computers are representative of such machines.
People use words and expressions to convey meanings.
Computers of the Sharp MZ-700 series, however, convey meaning through an ordinary television set or special printer. Any TV set can be used, either color or black-and-white; or, you may invest in one of the special display screens available if you want greater resolution and sharpness; you will be surprised at the beauty which is provided by such displays.
A tape recorder can be connected to computers of the Sharp MZ-700 series to record programs, the instructions which control the operation of the computer. When printed records of such programs or of
the results of computer processing are desired, they can be obtained on the MZ-700's compact, elegantly
designed 4-color plotter-printer.
MZ-731
Note: In the remainder of this manual, the term "MZ-700" will be used to indicate any of the computers
of the MZ-700 series (the MZ-711, MZ-721, and MZ-731).
10
1.2 Using this Manual
Before starting to study programming, why not try playing with the MZ-700 a bit? We're sure you want to do that anyway, rather than waiting until after you have read this book. First, read "Operating
the MZ-700" in Chapter 3 (you need read only those parts which apply to the model which you are us- ing). Connect the MZ-700 to a television, read the explanation of procedures for using the keyboard, and
learn which characters are output when each key is pressed.
If you are using the MZ-700 for the first time, read Chapters 1 and 2, in that order. At first, you may
find it difficult to grasp the meanings of the various commands and statements of the BASIC programming
language; however, even if you don't understand the explanations, be sure to key in the examples as
they are encountered. As you do so, you will gradually develop a concept of what BASIC is all about.
You may skip over those portions of Chapter 2 which start with 2. 8 "Machine Language Program
Control Statements"; however, these sections will prove useful when you have completely mastered programming in BASIC, or wish to become more familiar with the computer's internal operation.
If you have used the MZ-80K, you will find that the commands and statements of BASIC for the MZ-700 are used in the same manner as those of the SP-5025 family, so that the MZ-700 can be used in almost exactly the same manner as the MZ-80K. The major difference between the two is in the color statements (applicable to both the television screen and the color plotter-printer) which have been added; however, you should find it easy to become familiar with these by reading sections 2. 6 "Color display
statement" and 2. 7 "Color Plotter-printer Commands." Having done this, you will quickly be captivated by the power of expanded BASIC.
This manual also includes a discussion of "Operating the MZ-700" (Chapter 3), a reference section entitled "Hardware" (Chapter 4), a discussion of the "Monitor Commands and Subroutines" (Chapter 5),
and appendices of other information.
Now go ahead and learn everything you can about the MZ-700. We hope that you will find this manual helpful.
12
1.3 An Introduction to the World of Computers
1.3.1 What is BASIC?
People use language to communicate with each other, and specially designed languages are also used for
communication with computers. BASIC is one such language.
Beginner's All-purpose Symbolic Instruction Code
Just as human beings use languages such as English, French, German, and Japanese for communication, there are also many different languages which are used for communication with computers. Among these are BASIC, FORTRAN, COBOL, and PASCAL. Of these, BASIC is the computer language whose struc- ture is closest to that of the languages used by humans, and therefore is the easiest for humans to under- stand.
1.3.2 Loading BASIC into the MZ-700
The BASIC language must be loaded into the MZ-700 before it can be used to do any work. A cassette tape containing this language has been included in the case containing the MZ-700. Now let's teach the language to the computer; procedures for doing this are described below. (The explanation assumes that you are using an MZ-731; however, the procedures are basically the same for all computers of the MZ-
700 series.)
(1) Connect the display as described on page 106. (2) Turn on the power switch located on the back of the computer. (3) The following characters are displayed on the screen and a square, blinking pattern appears. This
pattern is referred to as the cursor.
X* MON I TOR 1 Z-01 3A XX
XSf
t
1
Cursor
(4) Set the cassette tape containing the BASIC language in the computer's data recorder. (5) Type in the word (l][o][a][d| and press the |CR| key. After doing this, the message ± PLAY appears
on the screen.
(6) Press the data recorder's | PLAY | button; the cassette tape starts moving and loading of the BASIC
language begins.
(7) After loading has been completed, the message READY is displayed and the cursor starts to
blink again.
Notes:
* i [IS®!! . . . This is the instruction for loading programs or data from cassette tape.
| CR| This is referred to as the carriage return key, and is mainly used to indicate comple-
tion of entry of an instruction.
13
r
** MSNfTOR 1Z-013A**
LOAD J. PLAY L3ADING BASIC '
BASIC INTERPRETER 1Z-01SBVX.XX
CorrKIQHT 1^83 By SHARP COW
XXXXX BYTES
READY
> 8
This completes loading of the BASIC program. You can talk to the computer using BASIC, and the
computer will respond.
1.3.3 Try Executing a Program
Loading BASIC into the computer doesn't cause it to do anything; first, it must be given instructions in BASIC as to what it is to do. Although we will not explain the instructions of BASIC until later, let's go ahead and try executing a BASIC program right now.
Remove the cassette tape from the recorder and turn it over so that the "B" side is up. A sample program is recorded on this side of the cassette tape. Using the following procedures, load this program into the computer and execute it.
(1) After turning the tape over and reloading it into the recorder, press the REWIND button to
rewind it. Next, type in [2[0][a][d] and press the |CR| key; when the message ± PLAY is display- ed, press the I PLAY | button on the data recorder. This begins loading of the sample program.
(2) When loading is completed, the cassette tape stops, READY is displayed on the screen, and the
cursor starts to blink again.
(3) Now that the program has been loaded into the computer's memory, try executing it. This is done
by typing in [r]|u]|n] and pressing the |CR| key.
(4) Now let's take a peek at the program. Hold down the 1 SHIFT key and press the 1 BREAK-]
key. This stops program execution and displays the words BREAK and READY, then the cursor starts to blink again.
(5) Type in [I][T][s][t] and press the | CR| key. This lists the lines of the program on the screen one
after another. (Output of the list can be temporarily stopped at any time by pressing the space bar.)
(6) If you wish to resume program execution, type in [r][u][n] again and hit the |CR[ key. (7) If you want to run a different program, set the cassette tape containing that program in the
recorder, LOAD the program, then RUN it. The previous program is automatically erased from memory when the new one is loaded, so the computer contains only "the BASIC language and the last program loaded.
14
BASIC
BASIC Programming
2.1 Introduction to Programming in BASIC
2.1.1 Direct Mode
Now that you have made some key entries on the MZ-700, you have reached the point where you are ready to start learning how to program. Before you start, however, try using the MZ-700 as you would an ordinary pocket calculator. (This is called operating the MZ-700 in the "direct mode".) Key in the following, just as you would on a pocket calculator.
f4ll+ll9lFllCRl
As you can see, the computer doesn't do anything when it is presented with a problem in this form;
your computer and an ordinary calculator are completely different in this respect, and instructions must
be entered in a form which can be understood by the computer (i.e, in the form prescribed by the BASIC language). Now try typing in the following.
fpiRimfNim SEEDER]
If you have done this correctly, the number "13" will be displayed and the screen will appear as shown below.
READY PR I NT
1 3
READY
Now let's try doing a somewhat more complex calculation.
With BASIC for the MZ-700, the operators (symbols) for the basic arithmetic operations are as follows.
Addition: + Subtraction: Multiplication: X (the asterisk) Division: / (the slash) Exponentiation: T
When symbols such a " X ", " + ", and " T " are mixed together in a single arithmetic expression,
the order in which calculations indicated by the symbols are performed is referred to as their priority. Just as with ordinary algebra, operations can be included in parentheses, so operations within the inner- most set of parentheses are performed first. Within a set of parentheses, exponentiation is performed
first, followed by multiplication and division (which have equal priority, and therefore are performed
as they are encountered in the expression, from left to right), and then by addition and subtraction.
For example, to obtain the answer to the expression 3 x 6 x C6 + 3 x !9 - 2 x (4 - 2) + II enter the
following.
4 + 9
PRINT is an instruction which tells the computer to display something on the screen. Here, the computer is instructed to display the sum of 4 + 9.
tsemem simsHEmsBEEBEEmHiBEnBfflmm
Now try using the computer to do a variety of other problems in arithmetic.
16
[EXERCISE]
[ANSWER]
6 + 4
6-4
2. 3X I5 + 9X (9-2)I +5
PR I NT (6+4)/(6—4)
5
PRINT 3X(5+9X(9-2)-6/(4-2)>+5
200
3. (3 + 4) x (5 + 6)
10+20
4.
5.
6x(2 + 3)
After going through the exercises, try typing in [T][I]@[8] and pressing the [CR| key; the answer "40" is displayed. The reason for this is that BASIC interprets the question mark in the same manner as the instruction PRINT. Remember this as a convenient, abbreviated form of the PRINT instruction.
Now try entering the following. (The quotation marks are entered by holding down | SHIFT and
pressing the [2] key.)
EememmsoEH EH
As you can see, the characters within quotation marks are displayed on the screen, but the answer is not. Now try entering the following.
6
10+20
x (2 + 3)
PRINT (3+4)X(5+6)
77
PRINT (1 0+20) /6X(2+3)
25
PRINT (1 0+20) /(6XC2 + 3))
1
EOfflmOTEOGEElGHEE]
This causes ABCDEFG to be displayed on the screen.
In other words, using the PRINT instruction together with quotation marks tells the MZ-700 to display characters on the screen exactly as they are specified between quotation marks. The characters within any set of quotation marks are referred to as a "character string" or "string".
Now go on to enter the following.
EememEmsBEBmssiHEJEE]
This causes the following to be displayed on the screen.
4 + 9 = ^1 3 (The "i_," symbol indicates a space. Actually, nothing is display-
ed on the TV screen in the position indicated by this symbol.) In other words, the instruction above tells the computer to display both the character string "4 + 9 =" and the result of the arithmetic expression "4 + 9 =". Now try entering the following.
fpiiRimif^mrni^RfoiFiFirTii^i+ifQiicH
After typing in this entry, the following should be displayed on the screen.
4 + 9 =
The reason the screen appears different this time is because the PRINT instruction displays items of information (character strings or the results of arithmetic expressions) differently depending on whether they are separated from each other by semicolons or commas.
Semicolon ( ;) Comma ( ,) .
1 3
Instructs the computer to display items immediately adjacent to each other. Instructs the computer to display the item at the position which is 10 spaces (columns) from the beginning of the display line.
If you have the MZ-731 (or a separate plotter-printer), now try appending the characters T/Pj to the
end of the word PRINT.
BemPfflOTHsm^FFimsm^ERi
This time nothing appears on the display screen, but the same result is printed out on the plotter-printer.
In other words, the T/Pj symbols switch output from the display to the plotter-printer.
This completes our explanation of procedures for using the MZ-700 as you would a pocket calculator.
Note: PRINT "5 + 8 ="; 5 + 8 displays 5 + 8=13, while PRINT
The reason for this is that one space is always reserved for a symbol indicating whether the result is positive or negative, but the symbol is only displayed in that space when the result is negative.
11
5 - 8 ="; 5 - 8 displays 5 - 8 = -3.
2.1.2 Programming
Let's try making a simple program. However, first let's make sure that the area in the computer's memory which is used for storing programs is completely empty. Do this by typing in NEW and pressing the|CRlkey. (This instruction will be explained in more detail later; see page 32.)
Type in the following program exactly as shown.
1 0 A = 3EE] Assigns the value 3 to A.
20 B = 6[CR] Assigns the value 6 to B. 30 C=A + Bffl Assigns the result of A + B to C. 40 9 OICRI Displays the value assigned to C.
50 E N PICRI Instruction indicating the end of the program.
The numbers 10, 20, 30, and so forth at the left end of each line are referred to as program line numbers, or simply line numbers; these numbers indicate the order in which instructions are to be executed by the
computer. Instructions on the lowest numbered line are executed first, followed by those on the next
lowest numbered line, and so forth. Line numbers must be integers in the range from 1 to 65535.
The line numbers 1, 2, 3, and so forth could have been used in this program instead of 10, 20, 30. However, it is common practice to assign line numbers in increments of 10 to provide room for later insertion of other lines.
Now let's check whether the lines have been correctly entered. Type in LIST and press the |CR[ key; this causes a list of the program lines to be displayed. Notice that the question mark entered at the beginn- ing of line 40 has been converted to PRINT, the full form of the command for displaying data on the display screen.
Novelet's try executing the program.
[RlPfNlfCRl
Enter RUN and press the |CR| key; the result is displayed on line 9 of the screen.
Now we will explain procedures for making changes in programs. First, let's change the instruction on line 20 from B = 6 to B = 8. Type in LIST 20 and press the [CR] key; this displays just line 20 of the program on the screen. Next, use the cursor control keys (the keys at the right side of the keyboard which are marked with arrows) to move the cursor to the number r6j, then press the 00 key and the |CR| key in succession to make the change. Note that the change is not completed until the|CR|key is pressed.
Now type in LIST and press the |CR| key again to confirm that the change has been made.
Next, let's change line 30 of the program to C = 30 X A + B.
Using the cursor control keys, move the cursor so that it is positioned on top of the "A" in line 30, then press the | INST | key three times in succession. This moves "A + B" three spaces to the right.
Cursor position
Now type in [3][o][x] and press the |CR| key to complete the insertion. LIST the program to confirm that the change has been made correctly.
Now change line 30 again so that it reads "C = 30 X A" instead of "C = 30 X A + B". Do this by
moving the cursor to the position immediately to the right of B and pressing the | DEL 1 key two times; this deletes "+B". Press the |CR| key to complete the change.
Now LIST the program and confirm that it appears as shown below.
1 0 A = 3 20 B = 8 30 C=30XA 40 PR I NT C 50 END
To delete an entire line from a program, simply enter the line number of that line and press the |CR| key;
delete line 20 in this manner, then LIST the program to confirm that the line has been deleted.
We could insert the instruction "?A" between lines 30 and 40, by typing in 35_?A and pressing the
|
CR[
key. Try this, then LIST the program to confirm that the line has been added. Now delete line 35 by
entering 35 and pressing the |CR| key.
The process of changing or inserting lines in a program in this manner is referred to as editing, and the program which results from this process is referred to as the BASIC text. Each line of the program can include a maximum of 255 characters, including the line number, but the maximum length is reduced
by four characters if the question mark is used to represent the PRINT instruction.
At this point, the program contained in the computer's memory should be as follows.
1 0 A = 3 30 C=30XA 40 PR I NT C
50 END
Now we will use this program to explain the procedures for recording programs on cassette tape.
Prepare a blank cassette tape (one on which nothing has been recorded) and set it in the data recorder,
19
then type in the following from the keyboard.
11
SAVE
CALCULATION" J
Here, "CALCULATION" is the name which is to be recorded on the cassette tape to identify the
program. Any name may be assigned, but the name connot be longer than 16 characters.
Note: The J symbol in the example above represents the |CR| key.
When the[CR]key is pressed, " ± RECORD. PLAY" is displayed on the screen. Pressing the I RECORD!
button on the data recorder at this time records the program on cassette tape.
The name which is assigned to the program is referred to as its file name. Specification of a file name is not absolutely necessary, but from the point of view of file management it is a good idea to assign one. Of course, the file name is recorded on the tape together with the program.
When recording is completed, READY is displayed to indicate that the computer is finished. Now press the STOP button on the data recorder and rewind the tape.
The program is still present in the computer's memory after recording is completed, so type in NEW J
to delete it (enter LIST J to confirm that the program has been deleted). Now let's try using the LOAD instruction to load the program back into memory from the cassette tape as described on page 14.
When a cassette tape contains many programs, that which is to be loaded can be identified by specifying the program's file name together with the LOAD instruction as follows.
LOAD "CALCULATION" J
Specifying the file name in this manner tells the computer to ignore all programs on the tape other than that with the specified name. If the file name is not specified (if only LOAD J is entered), the computer
loads the first program encountered.
Note: When using cassette recorder other than the data recorder built into the MZ-731, and MZ-721 read
the instructions on page 109 before attempting to record or load programs.
The LIST command shown above can be used in a variety of different ways. For example, during
editing LIST 20 J can be used to display just line 20 of a program. The entire program can be listed by entering LIST J . Other uses of the instruction are as follows.
omisim BlllCRl Lists all lines of the program to line 30.
•mem [3][0]B[CH] Lists all lines from line 30 to the end of the program,
•mom mEBEEaEE] Lists all lines from line 30 to line 50. omem mSJESBl Lists line 30.
When editing programs by listing individual lines with the LIST instruction, press the [ CLR | key (the
| INST | key) together with the | SHIFT ~| key when the screen becomes distractingly crowded. This
clears the entire screen and moves the cursor to its upper left corner. (This does not affect the program
in memory). Afterwards, enter LIST < line number > J again to list the line which is to be edited.
20
2.2 An Outline of BASIC
2.2.1 Constants
A constant is a number or string of characters which is written into a program, and which is used by that program as it is executed. Types of constants include numeric constants, string (character) constants, and system constants. These are explained below.
Numeric constants
A numeric constant is a number which has a maximum of 8 significant digits. The exponent of such constants must be in the range from 10"38 to 1038 (the maximum range is 1.548437E-38 to 1.7014118E
+38).
(Examples:)
-1 23. 4
0. 789
3748. 0
3. 7E + 1 2 3. 7X1012 1
7. 65E-9 7. 65X10"9 E indicates the exponent. 1 4. 8E9 1 4. 8X109 J
Hexadecimal numbers: Numbers can be specified in hexadecimal format only for direct memory addressing with the LIMIT, POKE, PEEK, and USR instructions (see pages 92 and 93), and are repre- sented as four digits preceded by a dollar sign ($).
(Examples:)
LIMIT SBFFF
USR CSC000, XS) X$ represents a string variable.
String constants
String constants are letters and symbols between quotation marks which are included in programs to allow titles or messages to be output to the display screen or printer. The characters " 4+9" appearing on page 17 are a character constant, and not a numeric constant. With BASIC, a string constant may consist of a maximum of 255 characters. (Not including quotation marks which cannot be included in a string constant.)
. (Examples:)
11
ABCDEFG
11
1 2345678910 "
DATA ABCDEFG Quotation marks are not needed when string constants are
11
specified in a DATA statement; however, they may be used if desired.
21
2.2.2 Variables
The word "variable" has a different meaning with BASIC than it does when used with regard to alge-
braic expressions. To put it in very simple terms, the variables of BASIC are "boxes" in memory for
the storage of numbers and characters (character strings). The types of variables used in BASIC include
numeric variables, string variables, and system variables.
Numeric variables String variables
System variables
SIZE
Numeric variables
Only numeric data can be stored in numeric variables. Names must be assigned to these variables in accordance with the following rules. i) A variable name may consist of any number of characters, but only the first two characters are
actually used by the BASIC interpreter to identify the variable. Further, the first character of the
variable name must be a letter (A to Z), either letters or numerals may be used for subsequent
characters.
ii) It is not possible to use the names of BASIC commands and statements as variable names.
Correct variable names: ABC, XY, ABCD, A12345
(ABC and ABCD are regarded as the same variable.)
Incorrect variable names: PRINT (PRINT is a BASIC statement)
C@ (Variable names may not include special charac-
ters.)
(Example:)
1 0 A = 5 Stores 5 in variable A. 20 PRINT A Displays the value stored in variable A.
22
String variables
String variables are variables which are used for storing character strings. Names assigned to string variables must conform to the same rules as those assigned to numeric variables; however a dollar sign ($) is appended to the end of string variable names to differentiate them from other types of variables.
String variables may be used to store a maximum of 255 characters. Such variables are blank until string data is assigned to them.
The only operator which can be used in expressions including more than one string variable is the
"+" sign.
(Example:)
10 A$= " A BCD " Substitutes the character string ABCD into string variable A$. 20 B$= " XYZ " Substitutes the character string XYZ' into string variable B$. 30 C$ = A$ + B$ Substitutes the sum of string variables A$ and B$ (ABCDXYZ)
into string variable C$.
40 PRINT CS Displays the contents of string variable C$.
System Variables
System variables contain values which are automatically changed by the BASIC interpreter. The system
variables are size (the variable which indicates the amount of BASIC free area) and TI$ (a 6-digit variable
which contains the value of the system's 24-hour clock).
(Examples:)
10 T I $= " 01 3500 " •• This statement assigns the value corresponding to 1:35:00 A.M.
to system variable TI$ and sets the system clock to that time.
20 PR I NT T I S Executing this statement displays the current time of the system
clock (24-hour time).
Display format:
132819 Indicates that the time is 13:28:19.
PR I NT S I Z E J This displays the current amount of free space in the computer's
memory (in other words, the amount of space which is available
for additional program lines). The value indicated by this variable is reduced each time a program line is entered.
23
2.2.3 Arrays
Arrays can be thought of as shelves within the computer's memory which contain rows of boxes, each
of which represents a variable. The boxes on these shelves are arranged in an orderly sequence, and are identified by means of numbers; these numbers are referred to as subscripts, because they are subscripted to the name which identifies the entire group of boxes.
Such shelves of boxes are set up simply by executing an instruction which declares that they exist; this is referred to as making an array declaration. The array declaration specifies the number of boxes which are to be included in each set of shelves (i.e., the size of the shelves) and the manner in which they are to be arranged.
The boxes in each unit of shelves may be arranged in sequences which have any number of dimensions. Thus, a one-dimensional array can be thought of as a single shelf which holds, one row of boxes; a two- dimensional array can be thought of as a stack of shelves, each of which holds one row of boxes; and so forth. These boxes, or variables, are referred to as the array's elements.
The number of subscripts used to identify each of the array elements of a corresponds to the number of dimensions in that array. For example, each of the elements in a one-dimensional array is identified by a single subscript which indicates the box's position in the row; each of the elements in a two dimensional array is identified by two subscripts, one which identifies the box's row, and one which indicates the box's position within that row; and so forth. The numbers which are used as the subscripts start with zero, and have a maximum value which is determined by the size of each of the array's dimensions (i.e., the number of boxes in each row, etc.).
The maximum size of an array is limited by the amount of free space which is available in the com- puter's memory (i.e., by the size of the program, the number of items of data which are to be stored in the array, and so forth). The syntax of BASIC places no restrictions on the number of dimensions which can be used for any array, but in practice the number of dimensions is limited by the amount of free memory space which is available for storage of array variables.
An array must be declared before values can be stored in any of its elements.
(Example 1)
10 DIM
20 DIM
10 DIM ACS), XSC8) Performs the same function as lines 10 and 20 above.
(Example 2)
10 DIM BC5, 5) Declares 2-dimensional numeric array B with 6x6
20 DIM YSC5, 8) Declares 2-dimensional string array Y$ with 6 x 9 elements.
10 DIM BC5, 5), YSC5, 8), AC5), XSC8) Declares two numeric arrays
(Example 3)
10 DIM CC3, 3, 3) Declares 3-dimensional array C with 4x4x4 elements.
Note: Different names must be used for each array which is declared; for example, the instruction DIM
A(5), A(6) is not a legal array declaration.
A(5)- X$(8)
Declares 1-dimensional numeric array A with 6 elements. Declares 1-dimensional string array X$ with 9 elements.
elements.
and two string arrays.
Try executing the program shown below and check the results which are obtained.
10 DIM AC2), BSC2) 20 A(0)=26 30 AC1 )= 9 40 A(2) = 1 00 50 B$(0)= "ABC ". 60 B$(1 )= " XYZ " 70 B$(2)= " MZ-700 " 80 PR I NT AC1 ) 90 PR I NT B$(2)
1 00 PR I NT AC2)
110 PRINT B$(0)+B$(1)
1 20 PR I NT A(0)
Note: Individual variables within an array, such as A(5) and X$(8), are referred to as an array's elements.
Numeric constants, numeric variables, and numeric arrays are collectively referred to as numeric expressions, and string constants, string variables, and string arrays are collectively referred to as string expressions.
25
2.2.4 BASIC Operations
In BASIC, arithmetic operations take a slightly different form than is the case with ordinary arithmetic. The various arithmetic operators used in BASIC are shown in the table below. The priority of these operators when they are used together within a single expression (the sequence in which the different arithmetic operations are performed) is as indicated by the numbers in the left column of the table; however, operators within parentheses always have the highest priority.
Arithmetic operations
Operator
1 t
2
3
4 Plus, minus
Operation Format
Exponentiation X t Y (Indicates XY; i.e., X to the Yth power.)
Negation
Multiplication,
division
-X
X X Y (X times Y), X/Y i.e., X divided by Y)
X + Y (X plus Y), X - Y (X minus Y)
(Example 1)
1 0 A=3X8/4 When a series of operators with the same priority are used in
an arithmetic expression, calculations are carried out from left to right; thus, the result of the expression at left is 6.
(Example 2)
10 A = 60-6X8 + 2---- Result is 14.
20 B= (60-6) X8 + 2 Result is 434.
(Example 3)
10 A = 2 T 3 Assigns 2 to the 3rd power to A; result is 8.
String operations
String operations are used to create new strings of character data by concatenating (linking) two or more shorter strings. The only operator which can be used in string operations is the "+" sign.
(Example)
PRINT " ABC " + " DEF " J » Displays the character string "ABCDEF".
26
2.2.5 Initial settings
Initial settings made when BASIC 1Z-013B is started are as described below.
Keyboard
1) Operation mode: Normal (alphanumeric)
2) Definable function keys
RUN" +CHRS (1 3) L I ST" AUTO" RENUM" COLOR"
Note A carriage return code is included in the definition of function key F1 .
Built-in clock The initial value set to system variable TI$ is "000000".
Music function
1) Musical performance tempo: 4 (moderato, approximately medium speed)
2) Note duration: 5 (quarter note J )
Control keys and control characters The control keys are keys which perform special functions when pressed together with the I CTRL I key.
Functions of these keys and their corresponding ASCII codes are as shown in the table below.
I SH I FT l +
I
SH I FT l+ I SH I FT l + I SH I FT l + I
SH I FT 14-
CHR$ ("
DEF KEY C CONT" SAVE" LOAD"
Control codes]
CTRL +
E
F
M 13
P
Q
R S
T 20 U V
W
X Y
Other The lower limit of the BASIC text area is set to address SFEFF; this is the same as LIMIT MAX is
executed).
For initial printer settings, see the discussion of the printer.
ASCII code
(decimal)
5
6
16 17 18 19
21 22
23 24
25
Function
Selects the lowercase letter input mode for alphanumeric characters. Selects the uppercase letter input mode for alphanumeric characters. Carriage return (|CR[). Same as the | DEL 1 key.
Moves the cursor down one line (O). Moves the cursor up one line (Hi). Moves the cursor one column (character) to the right (H). Moves the cursor one column (character) to the left (•). Moves the cursor to the home position ([ HOME |). Clears the screen to the background color ([ CLR ]). Places the computer in the graphic character input mode
(1 GRAPH |). Inserts one space (| INST |). Places the computer in the alphanumeric input mode.
-27
2.3 Frequently Used BASIC Commands and Statements
2.3.1 Program file input/output instructions
2. 3. 1. 1 LOAD (abbreviated format: LO.)
Format
Function
Note
LOAD or LOAD 1 filename" This command loads the specified BASIC text file or a machine language file to be linked with a BASIC program from cassette tape.
(See pages 14 and 20.)
Only BASIC text files and machine language programs can be loaded with this command. When the file to be loaded is a BASIC text file, the current program is cleared from the BASIC text area when the new program is loaded. When loading a machine language routine to be linked with a BASIC program, the LIMIT statement must be executed to reserve a machine language progam area in memory. Further, the applicable machine language program file is executed as soon as loading is completed if the loading address is inside that area. (In this case, the BASIC text is not erased.)
The LOAD command can be used within a program to load a machine language program file.
SOOOO
Monitor
$1 200
BASIC interpreter
BASIC text area LIMIT ($9FFF)
($ AOOO)
Machine language area
SFEFF
Note: The lower limit of the BASIC text area shifts according to the size the program text loaded.
28
Loading...
+ 217 hidden pages