ATOMIC THEORY AND PRACTICE

Contents Introduction - 1 BASIC PROGRAMMING Chapter 1 - Start Here 3 2 - Calculating in BASIC 11 3 - Planning a Program 17 4 - Writing a BASIC Program 23 5 - Loops 33 6 - Subroutines 39 7 - Arrays and Vectors 45 8 - Strings 57 9 - Reading and Writing Data 67 10 - More Space and More Speed 73 11 - Advanced Graphics 79 12 - What to do if Baffled 91 ASSEMBLER PROGRAMMING Chapter 13 - Assembler Programming 95 14 - Jumps, Branches, and Loops 105 15 - Logical Operations, Shifts, and Rotates 111 16 - Addressing Modes and Registers 117 17 - Machine-Code in BASIC 123 REFERENCE SECTION Chapter 18 - ATOM Operating System 131 19 - Cassette Operating System 139 20 - BASIC Statements, Functions, and Commands 143 21 - BASlC Characters and Operators 155 22 - Extending the ATOM 161 23 - Mnemonic Assembler 171 24 - Assembler Mnemonics 181 25 - Operating System Routines and Addresses 191 26 - Syntax Definition 199 27 - Error Codes 205 Index - 211 _i_

Introduction

This manual explains how to connect up the ATOM, and how to program it in BASIC or Assembler. The manual is arranged in three sections printed on different coloured paper. If you have never programmed before you should read the BASIC section, on plain paper, starting from Chapter 1; but be warned that you are setting off on an adventure which will require some changes of attitude towards computers. The only way to learn the art of programming is by practice, and so every section of this manual includes many example programs which illustrate the concepts being explained. These should be typed in and tried out, even if at first you do not fully understand how they work. By the end of chapter 4 you will be able to write your own programs for many different types of problem, and you may wish to stop there. The subsequent chapters, 5 to 12, deal with progressively more advanced features of the ATOM's BASIC. If you have already programmed in BASIC you may prefer to turn to chapters 20 and 21 in the reference section; these contain a complete summary of all the BASIC statements, functions, commands, and operators. You will be pleased to discover a number of extensions in ATOM BASIC that are not found in other BASICS. If you want to learn to program in Assembler you should turn to the second section of the manual which is printed on coloured paper, and read from chapter 13 onwards. Readers experienced in Assembler programming can jump to chapter 23 in the reference section, which gives a concise description of the ATOM assembler. The third section of the manual, printed on plain paper, is the reference section. It contains a summary of all the ATOM's facilities, a listing of the special addresses in the ATOM, and the error codes. If you have a minimal ATOM you will be able to run all programs whose sizes are given as less than 512 bytes, or which are so short that no size is given. Longer programs will require additional memory, but many programs can be reduced in size by using the abbreviations explained in chapter 10. Acknowledgements The preparation of this manual would not have been possible without the continuous assistance of everyone at Acorn. In particular I am grateful to Roger Wilson for providing details of the operation of the BASIC interpreter, and for assistance with editing the source of this manual; to Nick Toop for explaining many details of the ATOM's circuitry; and to Laurence Hardwick for testing the example programs. I would also like to thank the many people who provided comments on previous drafts of the manual. The following example programs were provided by Roger Wilson: Curve Stitching in a Square, Tower of Hanoi, Eight Queens, Prime Numbers, Arbitrary Precision Powers, Day of Week, Random Rectangles, and Renumber; and the following by Nick Toop: Simultaneous Equations, Encoder/Decoder, Three-Dimensional Plotting, and Saddle Curve. The manual was prepared and edited on an Acorn System Three, and the final artwork was prepared using the Acorn Text Processing Package. _1_

CONNECTIONS TO ATOM

ATOM KEYBOARD

_2_