The Electron User Guide


Part no 405000
Issue no 2
Date July 1984

CARE AND MAINTENANCE

Exposure
Like all electronic equipment, the Electron should not be exposed to direct sunlight for long periods.

Servicing
All servicing should be done through an authorised dealer. There are no servicable parts inside either the Electron or the mains adapter, and opening either case will void the warranty.

The mains adapter
Note that your Electron Microcomputer does not have a separate on/off switch, so to switch it off unplug the mains adapter.

To switch the computer off briefly, you can remove the small plug on the right hand side of the case. However, the mains adapter should not be left plugged into the domestic 13A socket for long periods if the Electron is not being used.

There is a thermal fuse built into the mains adapter and if this blows, you will need to replace the adapter (please contact your local dealer). The Electron Microcomputer contains its own short circuit protection, so adapter failure is unlikely.

UNDER NO CIRCUMSTANCES should the mains adapter be replaced by a normal mains plug. The mains adapter contains a transformer which reduces the mains to a safe low voltage for input to the Electron.

AUTHOR'S NOTE: Wherever the letters BBC are mentioned in this book they refer to the British Broadcasting Corporation.

© Copyright Acorn Computers Limited 1983

Neither the whole or any part of the information in, or the product described in, this manual may be adapted or reproduced in any material form except with the prior written approval of Acorn Computers Limited (Acorn Computers).

The product described in this manual and products for us with it are subject to continuous development and improvement. All information of a technical nature and particulars of the product and its use (including the information and particulars in this manual) are given by Acorn Computers in good faith. However, it is acknowledged that there may be errors or omissions in this manual. A list of details of any amendments or revisions to this manual can be obtained upon request from Acorn Computers Technical Enquiries. Acorn Computers welcome comments and suggestions relating to the product and this manual.

All correspondence should be addressed to:

Technical Enquiries
Acorn Computers Limited
Fulbourn Road
Cherry Hinton
Cambridge CB1 4JN

All maintenance and service on this product must be carried out by Acorn Computers' authorized dealers. Acorn Computers can accept no liability whatsoever for any loss or damage caused by service or maintenance by unauthorised personnel. This manual is intended only to assist the reader in the use of the product, and therefore Acorn Computers shall not be liable for any loss or damage whatsoever arising from the use of any information or particulars in, or any error or omission in, this manual, or any incorrect use of the product.

First published 1983
Published by Acorn Computers Limited
Typeset by Bateman Typesetters, Cambridge


Contents


1 What is a computer?    1
2 Getting started    2
Checklist of items   2
Additional items   2
Connecting the Electron to your television set   2
Connecting the Electron to the mains   4
Tuning the TV to the Electron   4
Push-button tuning   4
Single tuning knob   5
Connecting the Electron to a monitor   5
Monochrome monitor   5
Colour (RGB) monitor   5
Now try something   5

3 Using a cassette recorder   7
Introduction   7
Connecting a cassette recorder   7
Motor control   8

4 The Introductory Cassette   9
Adjusting the volume control and loading the first program    9
Loading each program from the cassette    14

5 How to use the keyboard   16
Introduction   16
Choosing the keyboard characters   18
SHIFT and CAPS LK   18
SHIFT   18
FUNC   19
The arrow keys and the COPY key   19
What the arrow and COPY functions do   19
Summary   20

6 Introducing commands and programs   21
What is hexadecimal?   23

7 Editing programs   24
Introduction   24
Listing the program   25
Editing programs   26
Editing with the arrow keys and the COPY key   26
Deleting lines from your program   28
Inserting new lines into your program   29
Renumbering the program   30
Getting the computer to number each program line   31
Putting notes into your programs   32
Retrieving a program and starting a new one   32
Listing long programs   33

8 Trying out some programs   34
Introduction    34
PERSIAN    34
POLYGON   35
DRAW   36

9 Recording programs on cassette   38
Saving (recording) a program on cassette   38
Checking a recording   39
Loading a program from cassette   39
Cataloguing the tape   41
What the numbers mean   41
Escape   41

10 The FUNC key and BASIC keywords   42
11 Variables and expressions   44
What is a variable?   44
Real variables   44
Operators and expressions   45
Rules for variable names   46
Integer variables   47
A% to Z%   47
Real versus integer variables   48
DIV and MOD   48
The TIME integer variable   49
String variables   49
Commands operating on strings   51
LEN   51
Linking strings   52
LEFT$, RIGHT$, MID$   52
VAL, EVAL, STR$   53
INSTR   53
STRING$   54
Comparison table of variables   54

12 Operator precedence   55
13 Arrays   56
14 READ...DATA...RESTORE   58
15 PRINT formatting and INPUT   59
PRINT formatting   59
INPUT   64

16 Conditional and loop instructions   68
The FOR . . . NEXT loop   66
The REPEAT . . . UNTIL loop   72
IF . . . THEN . . . ELSE   73

17 Procedures   77
Using parameters in procedures   81

18 GOTO and GOSUB   84
GOTO   84
GOSUB . . . RETURN   84
ON . . . GOTO, ON . . . GOSUB   86

19 Functions   87

20 Graphics   89
Introduction   89
Modes - what are they and why?   89
Writing text   90
The COLOUR command and text windows   90
Addresses on the text screen   90
Text windows   92
Defining your own characters   93
Graphics   95
Introduction   95
The graphics coordinate system   96
The GCOL command   97
The PLOT command   99
Advanced graphics   99
Triangle plotting   99
Sideways filling on background colour   99
Filling right   100
The VDU command   100
Graphics windows   101
The graphics origin   101
Plotting characters   102
The palette   102

21 VDU codes   104
Introduction   104
Detailed description   104

22 Making sounds   116
Introduction   116
The SOUND channel   116
The Q parameter   117
The A parameter   117
The P parameter   117
The D parameter   118
Using the SOUND command in a program   118
ENVELOPE   120
The ENVELOPE command   121
Constructing an ENVELOPE   121
Additional SOUND features   123
Example SOUND and ENVELOPE programs   125   

23 Address pointers, indirection operators   127
The Electron's memory   127
Indirection operators   129

24 User-programmable keys   131
For the more advanced   131

25 BASIC keywords   133
BASIC keywords   134

26 Cassette file handling   195
27 Error handling   198
28 Merging BASIC programs   200
29 Assembly Language   202
Introduction   202
Registers in the 6502   203
Accumulator   203
Index registers X and Y   204
Program counter   204
Stack pointer   204
Flags register   205
Addressing modes   206
Entering assembly mnemonics   210
Assembly   211
Execution by USR   214
Execution by CALL   214
Quadruple precision addition   220
Multiplication   221
Division   225
Error trapping in assembler   227
Operating system calls from assembler   228
Use of operating system calls   230
OSWRCH entry: &FFEE vector: &20E   230
OSASCI entry: &FFE3   232
OSNEWL entry: &FFE7   232
OSRDCH entry: &FFE0 vector: &210   233
OSCLI entry: &FFF7 vector: &208   234
OSFIND entry: &FFCE vector: &21C   234
OSBPUT entry: &FFD4 vector: &218   234
OSBGET entry: &FFD7 vector: &216   234
OSFILE entry: &FFDD vector: &212   234
OSBYTE entry: &FFF4 vector: &20A   235
OSWORD entry: &FFF1 vector: &20C   238
Events   242
Assembly Language mnemonics   243

Appendix A
VDU codes   265

Appendix B
Error messages   269

Appendix C
Operating system calls   278

Appendix D
*FX calls   280

Appendix E
Fast and efficient programs   284

Appendix F
ASCII displayed character set and control codes   285

Appendix G
Text and graphic planning sheets   287

1 What is a computer?


A computer is a general purpose electronic machine that can be instructed to do a great variety of things - play games, perform complex calculations, store and retrieve information, display graphs and so on.

You can ask a computer to do things directly - by typing commands on its keyboard - but for complex tasks, a whole series of instructions is usually written and stored in the computer's memory. The computer can be instructed to call up these instructions one by one and carry them out, very fast. (Your Electron can carry out, or 'execute', over 250,000 separate instructions every second.)

A series of instructions like this is called a program. Programs can be recorded onto cassette by using a suitable cassette recorder in much the same way as you might record a piece of music. The main difference is that the recording is made from a computer, and is played back into the computer again. You can buy pre-recorded programs which have been written by other people, and to start you off, several programs are provided on the Introductory Cassette which comes with your Electron.

The first part of this book describes how to set up your computer, and load and run the programs on the Introductory Cassette. For information on other programs available for the Electron (the general name for programs is 'software'), write to:

Acornsoft Limited
4a Market Hill
Cambridge CB2 3NJ

The remainder of this book (chapter 4 onwards), and the book Start Programming with the Electron, will tell you how to write your own programs on your Electron computer. You do not need to know this in order to use your computer, as there are many commercially available programs - but we hope that you will be interested and will want to find out more about your Electron.

<.HTML>