ebook img

The Sinclair ZX81: Programming for Real Applications PDF

170 Pages·1981·13.9 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview The Sinclair ZX81: Programming for Real Applications

The SINCLAIR ZX81 Programming for Real Applications Macmillan Computing Books Microprocessors and Microcomputers - their useandprogramming Eric Huggins TheAlien, Numbereater, and OtherProgramsforPersonalComputers - withnoteson how they werewritten John Race BeginningBASIC Peter Gosling ContinuingBASIC Peter Gosling Program Your Microcomputerin BASIC Peter Gosling Digital Techniques Noel Morris Microprocessor and Microcomputer Technology Noel Morris Understanding Microprocessors B.S.Walker Codesfor Computers andMicroprocessors P.Gosling and Q.Laarhoven Z80AssemblyLanguageProgrammingfor Students Roger Hutty The SINCLAIR ZX81 Programming for Real Applications Randle Hurley M © Randle Hurley 1981 Allrights reserved. No part ofthispublication may be reproduced or transmitted, inanyformorbyanymeans, withoutpermission. Published 1981 by THE MACMILLAN PRESS LTD Londonand Basingstoke Companies and representatives throughout theworld ISBN978-0-333-32973-3 ISBN978-1-349-06315-4(eBook) DOI 10.1007/978-1-349-06315-4 The paperback editionofthis bookissoldsubject tothe conditionthat it shallnot,bywayoftrade orotherwise,belent,resold, hiredout, or otherwisecirculated withoutthepublisher'sprior consent inanyform ofbindingorcoverotherthan that inwhichitispublished andwithout asimilarconditionincludingthiscondition beingimposedonthe subsequent purchaser. Contents I Aims and Assumptions 2 Programming 3 Saving Time and Space 4 Word Juggler 5 Money 6 Personal Finances 7 Banking 8 Bulk Storage 9 Rank Order 10 Exam Result Analysis II Hardware Modifications I would like to express my gratitude to all the ZXBO and ZXBl enthusiasts who have contributed towards this book. Some made their contributions directly but the majority will probably be oblivious of having helped. During countless conversations centring round the machines, chance remarks have sparked off the ideas which led to the finished programs in this work. Steve Adams made many of the direct contributions and his idea on modifying the 3K RAM pack is included in the chapter on hardware. However you made your contribution, thanks. Particular thanks must go to my wife, Linda. The original idea was that she should read and criticise the material from a com plete beginner's point of view but she learned so fast that she became the major bug finder and editor as well. Thanks, love, I couldn't have got half way through without you. 1 Aims and Assumptions When I sat down first to work my material into a book I had to make some assumptions about the sort of reader that I was writing for. The person that I had in mind when writing was not a computer expert. My target reader had finished all the material in the Sinclair manual and probably did not really understand those bits about Procrustean Assignment and Unary Functions. He or she will probably have read a book or two of games programs and perhaps will have been interested in some of the ideas presented in the pages of magazines devoted to the ZX81. My reader may have shared my frustration that these ideas, while fascinating, are given in isolation and seldom related to any real task the ZX81 may be called on to do. The person I am writing for may be a teacher like myself, hoping to use their machine for academic organisation or as an educational tool. On the other hand, I may be writing for someone interested in using the ZX81 to help run a small business or a social club. All these possible needs have been borne in mind during the writing. The program listings shown in these chapters not only work, they are workhorses, doing real jobs in a variety of environments. Each of the ideas presented has been followed through to a real conclusion and not used simply to illustrate a nice programming point. Lack of finance for a larger machine meant that the ZX81 simply had to do my data processing work. Necessity forced me to consider alternative ways of using the ZX81's BASIC and these alternatives have proved to be very useful. None of the ideas used in the programs shown is highly technical and so they will all be quite easy for even a relatively inexperienced programmer to understand. Expect to find a logical extension of the material in the handbook and some interesting twists in the way that it has been put to work. 1 While we'are still on the subject of assumptions, I have assumed that the reader has a fully expanded machine. Some of the programs occupy the whole of the 16K RAM pack and all of them are too big for the 1K ZX81. The ZX printer has been considered and commands for it have been written into some of the programs. In all but one case the programs will work satisfactorily without this extra. The word processing package, however, really does rely on the availability of a printer for most of its uses. Towards the end you will find a chapter on some simple hardware modifications. Anyone who has built the kit will find no difficulty in making the modifications but, while they more than repay the small amount of work involved, these are in no way necessary for the smooth run ning of the programs. Games programs teach a lot about how the computer works and about the facilities available on the machine but even the most avid games player will eventually tire of the material on offer and will look for alternatives. And then there are those awkward people who keep on asking the classic question: "that's interest ing, but what is it forT' A glance through the contents of the book will be enough to provide several answers to the askers of this question and at the same time dispute the idea that the ZX81 is a toy computer, suitable only for keeping the children quiet on wet afternoons and for drilling them in their arithmetic. The central processor of the ZX81 is the same Z80A chip found in many, much larger machines which run commercial organisations. If this chip can run a wages and stock control system or a word processor when built into other computers then there must be a lot of un tapped potential in the ZX8l and my aim has been to exploit this. I hope that those readers who have tired of the normal diet offered to ZX81 users will share in the great satisfaction that I have had from coaxing the little machine to take on tasks normally thought to demand a much larger computer. A quick flip through the pages which follow might give the impression that the contents are much the same as to be found in all the other books of programs; large chunks of not very intel ligible code and hardly the thing for someone who has just closed the pages of the handbook for the first time. Well, look again. The chunks are all quite small, seldom more than about ten lines. The reader has very little to key into the machine at anyone time and the likelihood of a line being missed from a long listing is reduced considerably. Now look closer still. All the code is accompanied by little bits in English. Every line which is the slightest bit difficult to understand is explained there and then. Readers are not expected to have infal lible memories, if the same idea crops up in a later line then the explanation is given again. The information in English that accompanies the code, the documentation, is not limited to ex plaining the hard bits. All the GO TO instructions are accompanied 2 by notes on the material to be found at the line that the computer is to jump to. GO SUB lines carry reminders of what it is that each subroutine does. On the occasions that PEEK and POKE com mands are used, information on the identity of the value being "peeked at" and the purpose of the number being "poked" is given in full. Where the logical structure of the program is spread over a large number of lines and is difficult to grasp as a whole then the explanatory notes are supplemented by a flow chart. The first chapter after this introduction is on programming. This is not intended to be a course in BASIC. It is a supplement to the handbook material and looks at ways of making the fullest possible use of the ZX81 facilities. In places, this chapter reads a little like a list of household tips. Even such small matters as the type of exercise books to consider and the benefits of shelf lining paper are covered. Later, the cost of all the com mands and the functions is investigated in terms of both memory use and running time. These investigations are built up into some general observations on programming the ZX81 more effectively. The main aim of the book is to develop in the reader an inter est in pushing the ZX81 computer much further than anyone expected it to go when it was first launched. The programs will show you how to store more numbers than there are memory bytes in the 16K machine and then access this idea in many different ways after wards. You will find the necessary information on how to reduce the likelihood of your programs crashing the moment they are handed over to an inexperienced user. Ways of storing large amounts of text which remain available for editing and ways of storing numbers as text to improve storage efficiency will be made available to you. More important than all this, however, after reading the material you should have discarded the belief that the ZX81 is too small for any real computing work. The programs given here are just the beginning; the techniques are flexible enough to be worked into your own programs to fill your own data process ing needs. The material can be approached at two levels. On the one hand, there are large, powerful, "off the peg" programs which can be put to work at once or modified to suit particular needs. Alter natively, you can use the programs as working examples to illus trate the programming ideas given in the early part of the book. The ideas and the examples can then be used as a basis for the development of entirely new and different programs for completely different applications. I hope that most readers will approach the material from both angles at different times. Teachers, by the way, may find ideas of interest in the non-educational programs and I hope that those of you without an involvement in education will enjoy the programming ideas in the educational material. 3

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.