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

391 All the *FX commands can be typed in in immediate mode or can be included as a line of a BASIC program. The values typed in for x and y (if any) are copied by the MOS into registers known as X and Y, which reside in the microcomputer’s 6512 microprocessor (see next chapter for more details). Some *FX commands return values in X and Y, but unfortunately the MOS does not copy these returned values back into X% and Y% (it doesn’t even ‘know’ about X% and Y%). However, this drawback can be overcome through the use of a certain operating system call. An operating system call is a means of activating one of the routines which exist within the MOS.

Several operating system calls exist, which perform a variety of functions (see chapter 45). The operating system call which we will examine first is OSBYTE. OSBYTE calls from BASIC OSBYTE has call address &FFF4, a memory location within the operating system ROM. This means that when OSBYTE is called, the instruction held in location &FFF4 is executed. This instruction loads an address which is held in a RAM location whose address is given in locations &FFF5 and &FFF6 (&020A for OSBYTE). OSBYTE is said to ‘indirect’ via &20A. Locations &20A and &20B contain the address of (or the ‘vector’ to) the routine within the MOS which is actually executed.

This may seem a little complicated, but it does mean (for example) that OSBYTE’s call address will always be &FFF4, and its indirection vector will always be at &20A, no matter how much the MOS changes between different versions. OSBYTE can be called from within BASIC in two ways, one of these being with the CALL BASIC keyword. Try typing the following sequence: A%=0 X%=0 Y%=0 CALL(&FFF4) You will notice that this has exactly the same effect as the *FX0 command. This is because a *FX command and an OSBYTE call are very nearly one and the same thing: the MOS recognises any command beginning *FX as an OSBYTE call. in general, *Fxa,x,y is equivalent to OSBYTE with A=a, X=x and Y=y.

A is another register in the 6512 (known as the ‘accumulator’, see chapter 45) whose contents are set equal to the value read by the BASIC interpreter from the resident integer variable A%. As another example, the following program would have the same effect as *FX9,10 (see above):