Acorn Computers BBC Micro Model B w/8271 — Acorn BBC Micro Model B w/8271 User Guide Manual PDF

393 10 REM Uses OSBYTE with A=129 to wait one second for a key 15 REM to be pressed. 20 DIM registers 4 30 DIM A$(2):A$(0)="A=":A$(1)="X=":A$(2)="Y=" 40 A%=129 50 X%=100 60 Y%=0 70 !registers=USR(&FFF4) 80 FOR K=0 TO 2 90 PRINT A$(K);~registers?K 100 NEXT K This program uses OSBYTE with A=129 to read a key, which must be pressed within a specified time limit (one second in the example). If it reminds you of BASIC’s INKEY keyword that’s because INKEY uses the same OSBYTE call. If a time limit of n centiseconds is required then X and Y should be set up as follows:

X=n AND &FF Y=n DIV &100 The exit conditions vary according to what happens; if no key is pressed within the time limit, X is preserved, Y=&FF. If a key is pressed, X returns the hexadecimal ASCII code of the key character, Y=0. All the *FX calls and OSBYTE calls available on the BBC Microcomputer are detailed at the end of this chapter, preceded by a numerical and a functional summary. Other calls are available to various filing systems which may not be fitted to your machine; these are noted, but you are referred to the appropriate filing system user guide for details.

OSBYTE calls from assembly language This section does not attempt to provide an introduction to assembly language and how to use it; you are referred to the next chapter for that. For those unfamiliar with the concept of assembly language, it is safe to assume for now that it is a sort of ‘half way house’ between BASIC and machine code, which is what the 6512 microprocessor actually executes. Programs written in assembly language are more difficult to write than BASIC programs, but they usually take up less memory and are faster than an equivalent BASIC program, which is why large, complex programs such as arcade games will always be written in assembly language.