Contents / Reference section / Previous chapter / Next chapter / Index


42 FX calls and OSBYTE calls

FX and OSBYTE Call Summary

Decimal Hex Function

* 0 0 Prints operating system version number
1 1 Reserved for application programs
2 2 Selects input device
3 3 Selects output devices
* 4 4 Enable/disable cursor edit keys
* 5 5 Select printer type
* 6 6 Set Printer ignore character
* 7 7 Set RS423 receive baud rate
* 8 8 Set RS423 transmit baud rate
* 9 9 Set flash period of first colour
* 10 A Set flash period of second colour
* 11 B Set auto-repeat delay
* 12 C Set auto-repeat period
13 D Disable various events
14 E Enable various events
* 15 F Flush all or just input buffer
* 16 10 Select number of ADC channels
17 11 Force start of conversion on ADC channel
18 12 Reset user defined function keys
19 13 Wait for field synchronization
20 14 Explode soft character RAM allocation
21 15 Flush selected buffer
* 124 7C Reset ESCAPE flag
* 125 7D Set ESCAPE flag
* 126 7E Acknowledge detection of ESCAPE condition
* 127 7F Check end of file status
* 128 80 Read ADC channel/fire buttons/last
conversion
* 129 81 Read key within time limit
* 130 82 Read machine high order address

Decimal Hex Function

* 131 83 Read top of operating system RAM Address
* 132 84 Read bottom of display RAM address
* 133 85 Read lowest address for particular MODE
* 134 86 Read text cursor position
* 135 87 Read character at text cursor position
136 88 Reserved
* 137 89 Turn cassette motor ON/OFF
138 8A Insert character into keyboard buffer
* 139 8B Set file options
* 140 8C Select cassette file system and set speed
141 8D Reserved
142 8E Reserved
143 8F Reserved
* 144 90 Alter TV display position/interlace
145 91 Remove character from buffer
146 92 Read from I/O area FRED
147 93 Write to I/O area FRED
148 94 Read from I/O area JIM
149 95 Write to I/O area JIM
150 96 Read from I/O area SHEILA
151 97 Write to I/O area SHEILA
224 E0 Cancel VDU queue
225 El Set base number for function-key codes
226 E2 Set base number for SHIFT function-key codes
227 E3 Set base number for CTRL function-key codes
228 E4 Set base number for SHIFT/CTRL function key codes
229 E5 Escape =& 1B
230 E6 Enable/disable normal ESCAPE key action
231 E7 Enable/disable user 6522 IRQ
232 E8 Enable/disable 6850 ACIA IRQ

This sheet gives OSBYTE calls for issue 1.0.

Calls marked * are identical in issue 0.10. Those calls with no mark are new to the issue 1.0.

The statement *FX is used to control a large number of the computer's "special effects", for example the rate at which "flashing colours" flash or to select whether an RS423 or a parallel printer is to be used. For example, to select a parallel printer and to copy all output to the printer one would use the statements.

10 *FX 5,1 selects parallel printer

20 VDU 2 copies all output to printer

Please note that not all the calls listed are available on operating systems before "Issue 1.0".

The FX calls are also easily available to those writing in assembly language. In this case the same effect of selecting a parallel printer and turning it on would be achieved by

10 DIM DEMO 20

20 OSBYTE=&FFF4

30 OSWRCH=&FFEE

40 P%=DEMO

50 [

60 LDA #5

70 LDX #1

80 JSR OSBYTE

90 LDA #2

100 JSR OSWRCH

110 RTS

120 ]

300 CALL DEMO

>RUN

0EA4

0EA4 A9 05 LDA #5

0EA6 A2 01 LDX #l

0EA8 20 F4 FF JSR OSBYTE

0EAB A9 02 LDA #2

0EAD 20 EE FF JSR OSWRCH

0EB0 60 RTS

Because this chapter is relevant to both those writing BASIC programs and those writing in assembly language, a certain amount of material has to be included that is only relevant to those writing in assembler. The next section is a case in point; it is only relevant to those programming in assembly language.

All FX calls are available in machine code. In general an FX call in BASIC takes the form

*FX 137,0,1

In assembly language the general form is

LDA #137

LDX #0

LDY #1

JSR &FFF4

The first parameter (137) determines which FX call is to be used and is placed in the accumulator. The second and third parameters are optional but if used are placed on the X and Y registers.

If omitted X and Y will be set to zero. Thus *FXa would set X and Y to zero and *FXa, X would set Y=0.

Before using an OSBYTE call (JSR &FFF4) the 6502 must be in binary mode. In general, after an OSBYTE call the registers and flags will be undefined. Some OSBYTE calls return a value in X. These are noted further on. OSBYTE calls with A in the range &80 to &FF in general need to set both X and Y whereas other OSBYTE calls only take one argument - in X.

As you may gather, the *FX statement merely takes the

parameters given, places them in A, X and Y and executes a call to &FFF4.

Some FX statements return values in the X (and sometimes Y), register. They can only be used by assembly language programmers or by using the USR function in BASIC. For that reason they are explained as OSBYTE calls rather than FX calls.

See section 43 (Assembly Language) for more information.

Each FX and OSBYTE call is now explained in detail.

*FX 0 prints a message giving the version number of the operating system.

*FX 1 is reserved for user supplied routines in application programs.

*FX 2 selects the input device from which characters will be fetched.

*FX2,0 get characters from the keyboard and enables the RS423 receiver.

*FX2,1 gets characters from the RS423 port

*FX2,2 gets characters from the keyboard and enables the RS423 receiver.

This call is not available in operating systems prior to issue 1.0.

*FX 3 is used to select whether output appears (or not), on three different output streams. In the table below screen refers to the normal TV or monitor, RS423 refers to the RS423 socket and Printer refers to the selected printer output which may be either parallel or RS423.

The number following *FX3, will produce output on the following devices

Printer Screen RS423
(bit 2) (bit 1) (bit 0)
*FX3,0 x
*FX3,1
*FX3,2 x x
*FX3,3 x
*FX3,4 x x
*FX3,5 x
*FX3,6 x x x
*FX3,7 x x

Thus, to send output to the RS423 but not to the screen or printer one would use *FX3,7

At machine code level bit 0 controls the RS423 stream, bit 1 the VDU screen and bit 2 the printer. Note that bits 1 and 2 are negative logic true so that *FX3,0 will select the printer and screen outputs. This is the default setting.

*FX4,0 resets the system so that the cursor editing keys and COPY, perform their normal cursor editing function.

*FX4,1 disables the cursor editing and makes the cursor editing keys generate normal ASCII codes. The codes are shown below in both decimal and hex. numbers.

135 &87

136 &88

137 &89

138 &8A

139 &8B

*FX4,2 permits the ←→↑↓ and COPY keys to be programmed in the same way as the user-defined function keys. In other words they may contain strings. In this case the *KEY number are

COPY 11

← 12

→ 13

↑ 14

↓ 15

This feature is only available from issue 1.0.

*FX5 is used to select the printer type.

*FX5,1 selects output to the parallel (Centronics ® type) output connector.

*FX5,2 selects the serial RS423 output.

*FX5,3 selects a user-supplied printer driver (see page 408).

Note that neither of these will actually cause output to appear on the printer. VDU 2 (or CTRL B) must be used to start output going to the selected printer channel.

*FX5,0 can be used to select a "printer sink" where characters can be lost without the possibility of the system "hanging" with a full printer buffer.

*FX6 is used to set the character which will be suppressed by the printer driver routines. Some printers do an automatic "line feed" when they receive a "carriage return". It is therefore useful to be able to prevent the "linefeed" characters from reaching the printer. The ASCII code for line feed is decimal code 10 so this can be achieved with the statement

*FX6,10

Having set this mode it is still possible to get a line feed through to the printer by use of VDU1 (send next character to printer only) statement. The character following VDUl is not checked, thus to send a line feed one would use

VDU1,10

*FX6 should always be executed after the printer type has been set by *FX5.

Note that the default is that line feed characters are filtered out.

*FX7 is used to select the baud rate to be used when receiving data on the RS423 interface, as follows:

*FX7,1 75 baud receive
*FX7,2 150 baud receive
*FX7,3 300 baud receive
*FX7,4 1200 baud receive
*FX7,5 2400 baud receive
*FX7,6 4800 baud receive
*FX7,7 9600 baud receive
*FX7,8 19200 baud receive (This rate is not guaranteed)

*FX8 is used to select the transmit rate to be used on the RS423 interface:

*FX8,1 75 baud transmit
*FX8,2 150 baud transmit
*FX8,3 300 baud transmit
*FX8,4 1200 baud transmit
*FX8,5 2400 baud transmit
*FX8,6 4800 baud transmit
*FX8,7 9600 baud transmit
*FX8,8 19200 (This rate is not guaranteed)

Note: The standard receive/transit format adopted for RS423 is a 1 start bit, 8 data bits, 1 stop bit.

*FX9 and *FX10 are used to set the flash rate of "flashing colours". Colours always flash between one colour and its complement. Thus in MODE 2, COLOUR 9 selects flashing red-cyan. (See page 381 for more information on COLOUR.)

*FX9 is followed by a number which gives the duration of the first named colour. The duration is given in fiftieths of a second. Thus to select one-fifth of a second one would use the statement

*FX9,10

The default is *FX9,25

*FX10 is used to set the period of the second named colour. See the entry above for *FX 9.

Note that values of 0 for the duration will eventually force the selected state to occur fulltime. If neither counter is set to zero then setting the other counter to zero will immediately force the latter colour to appear.

The default is *FX10,25

*FX11 If a key is held depressed then after a short delay (the auto-repeat delay), the key will repeat automatically every so often. The delay is given in centi-seconds.

*FX1l sets the delay before the auto-repeat starts.

*FX1l,0 turns off the auto-repeat all together.

*FX1l,5 would set the auto-repeat delay to five hundredths of a second, etc.

*FX12 sets the auto-repeat period, that is the amount of time between the generation of each character.

*FX12,0 resets both the auto-repeat delay and the auto-repeat to their normal values.

*FX12,10 would set the auto-repeat period to ten-hundredths of a second thus producing ten characters per second.

*FX13 and *FX14 are used to enable and disable certain "events". These FX calls will only be used by those writing in assembly language and more information on "Events" is given on page 464. The summary which follows should be read in conjunction with that section.

*FX13,0 disable output buffer empty event.

*FX13,1 disable input buffer full event.

*FX13,2 disable character entering input buffer event.

*FX13,3 disable ADC conversion complete event.

*FX13,4 disable start of vertical sync. event.

*FX13,5 disable interval timer crossing zero event.

*FX13,6 disable ESCAPE pressed event.

These calls are only available from issue 1.0.

*FX14,0 enable output buffer empty event.

*FX14,1 enable input buffer full event.

*FX14,2 enable character entering input buffer event.

*FX14,3 enable ADC conversion complete event.

*FX14,4 enable start of vertical sync. event.

*FX14,5 enable interval timer crossing zero event.

*FX14,6 enable ESCAPE pressed event.

These calls are only available from issue 1.0.

The initial condition is that all are disabled.

*FX15 enables various internal buffers to be flushed (or emptied).

*FX15,0 flushes all internal buffers.

*FX15,1 flushes the currently selected input buffer

See also *FX21

As an OSBYTE call this typically executes in 370 micro-seconds in release 1.0.

*FXl6 is used to select the number of Analogue to Digital Converter (ADC) channels that are to be used. Each ADC channel takes 10ms to convert an analogue voltage into a digital value. Thus if all four ADC channels are enabled then new values for a particular channel will only be available every 40ms. It is, therefore, often wise to only enable the number of channels actually required.

*FX16,0 will disable all ADC channels.

*FX16,1 will enable ADC channel 1 only.

*FX16,2 will enable channels 1 and 2.

*FX16,3 will enable channels 1, 2 and 3.

*FX16,4 will enable all four ADC channels.

*FXl7 forces the ADC converter to start a conversion on the selected channel. Thus *FX17,l will start a conversion on channel 1. Channels are numbered 1, 2, 3 and 4. OSBYTE call with A=&80 can be used to determine when the conversion is complete as can ADVAL(0).

This call is only implemented from issue 1.0.

*FX18 Resets the user defined function keys so that they no longer contain character strings.

This call is only implemented from issue 1.0.

*FX19 Causes the machine to wait until the start of the next frame of the display for animation. This call is only implemented from issue 1.0.

*FX20 When the machine starts up, space is allocated at &C00 for the re-definition of 32 displayed characters using the VDU 23 statement.

In operating system 0.10 ASCII characters 224 to 255 can be redefined into this space. In operating system 1.0 a new concept is introduced namely that of "exploding" the memory allocation for user defined characters. What follows refers only to version 1.0 but care has been taken to ensure upward compatibility with operating system 0.10.

In the initial state, or after issuing a *FX20,0 command, the character definitions are said to be "imploded". This means that an attempt to print any character with ASCII code greater than 128 (&80) will be mapped on to the characters stored at memory &C00. Initially this will produce garbage. Once a user defined character has been defined it will then appear at four ASCII positions due to this mapping. Thus ASCII codes &80, &A0, &C0 and &E0 will all show the same character.

Re-defining ASCII code &E0 (224) will affect all four characters. An attempt to re-define codes between &20 and &7F will be ignored

After a *FX20,1 command the character definitions are said to be "exploded" and all printing characters (codes &20 to &FF) can be re-defined. However, until any character in a block is re-defined, the block will map on to either the pre-set ROM (&20 to &7F) or on to memory at &C00 (&80 to &FF). The memory allocated to each block of ASCII codes in the "exploded" state is

ASCII code Memory allocation
&20 to &3F OSHWM + &300 to OSHWM + &3FF
&40 to &5F OSHWM + &400 to OSHWM + &4FF
&60 to &7F OSHWM + &500 to OSHWM + &5FF
&80 to &9F &C00 to &CFF
&A0 to &BF OSHWM to OSHWM + &FF
&C0 to &DF OSHWM + &100 to OSHWM + &1FF
&E0 to &FF OSHWM + &200 to OSHWM + &2FF

Thus if the user re-defines characters in the range &20 to &3F he must leave memory up to OSHWM + &3FF clear of his program. This is done by first finding the value of OSHWM (for the particular configuration in use) by using OSBYTE call 131 and when setting PAGE to a value &400 above this value. Of course, if the user only wishes to re-define ASCII codes in the range &80 to &9F (128 to 159) then he need not alter PAGE.

Codes in the range &80 to &9F are of particular importance since the user can generate them directly from the keyboard by holding down SHIFT at the same time as pressing one of the user definable function keys (issue 1.0 only).

See page 431 for more information on Operating System High Water Mark.

*FX20 is only available from issue 1.0.

*FX21 This call allows any internal buffer to be emptied (or flushed).

*FX21,0 flushes the keyboard buffer

*FX21,1 flushes the RS423 serial input buffer

*FX21,2 flushes the RS423 serial output buffer

*FX21,3 flushes the printer output buffer

*FX21,4 flushes the SOUND channel number 0 (noise)

*FX21,5 flushes the SOUND channel number 1

*FX21,6 flushes the SOUND channel number 2

*FX21,7 flushes the SOUND channel number 3

*FX21,8 flushes the speech synthesis buffer

See also *FX 15 and OSBYTE &80

This call is only implemented from issue 1.0.

*FX124 Can be used to reset the ESCAPE pressed flag at location &FF. It must not be set or reset directly.

*FX125 Sets the ESCAPE pressed flag. It must be set with this call and not directly. It has a similar effect to pressing the ESCAPE key. (Conditional on any OSBYTE 229 call.)

*FX126 Must be used to acknowledge the detection of an "escape condition" if the user is intercepting characters fed into the computer through the OSRDCH (Operating System Read Character) routine.

OSBYTE calls

Most of the calls that follow can only be used in machine code programs. They are therefore described in terms of an OSBYTE call - that is, a JSR to location &FFF4. The call number is passed in the A accumulator and the X and Y registers are used to pass other values. Values are returned in X and/or Y. It is however possible to use these calls from BASIC by using the USR function, provided that the result is deposited in an integer variable.

OSBYTE with A=&7F (127) (EOF#)

This call returns the end-of-file status of a file which has been previously opened. On entry X should contain the channel number allocated to the file. On exit X will be zero if the end-of-file has not been reached and X will be non-zero if the end-of-file has been reached.

OSBYTE with A=&80 (128) Read ADC channel (ADVAL)

This call returns the most recent value of a particular Analogue to Digital Converter channel. It can also be used to detect an end of conversion and to see if the Games Fire buttons are pressed.

On entry X contains the channel number to be read. If X is in the range 1 to 4 then the specified channel will be read and on exit the 16 bit value will be return in X and Y. Y will contain the 8 most significant bits and X the 8 least significant bits.

If on entry X=0 then on exit Y will contain a number in the range 0 to 4 indicating which channel was the last to complete. Note that *FX16 and *FX17 reset this value to 0. A value of zero indicates that no channel has completed. Also on exit the two least significant bits of X will indicate the status of the two "fire buttons". The user should always AND X with 3 to mask out high order bits.

If on entry X contains a negative number (in 2's complement notation) then the call will provide information about various input buffers. On entry Y must contain &FF.

X on entry Buffer checked
255 keyboard buffer
254 RS423 serial input buffer
253 RS423 serial output buffer
252 printer output buffer
251 SOUND channel 0 (noise)
250 SOUND channel1
249 SOUND channel2
248 SOUND channel3
247 speech buffer

On exit X contains a number giving, for input butters, the number of characters in the buffers. For output buffers X contains the number of spaces still free in the buffer.

OSBYTE with A=&81 (129) Read key with time limit

The call waits for character from the current input channel until a time limit expires or it tests a particular key. The BASIC function INKEY uses this call. The programmer is reminded that this call will immediately obtain characters if the user has "typed ahead". It is, therefore, often necessary to flush the input buffer with *FX15,1 before using this call.

The maximum time delay is passed to the subroutine in X and Y. The delay is measured in centi-seconds and Y contains the most significant byte and X the least significant byte. The maximum delay is &7FFF centi-seconds which is about five-and-a-half minutes.

On exit the Y=0 if a character was detected within the time limit. In this case X contains the character. Y=&1B indicates that ESCAPE was pressed. This must be acknowledged with *FX126. Y=&FF indicates a time-out.

If on entry Y contains a negative number then the routine can be used to check for a specific key closure. See the BASIC keyword INKEY for more information.

As an OSBYTE call a "check for character waiting with zero delay" takes typically 130 micro-seconds in release 1.0.

OSBYTE with A=&82 (130) Read machine higher order address

The BBC computer uses a 6502 processor which requires a 16 bit address. However a number of routines require a 32 bit address - for example most file system addresses are 32 bits wide to ensure compatibility with future products. A specific "high order address", that is the top 16 bits of the tota1 32 bit address, is allocated to the present BBC computer. This call generates the high order address for each machine. The high order address is returned in X and Y with Y containing the most significant byte and X the least significant byte.

OSBYTE with A=&83 (131) Read top of O.S. RAM address (OSHWM)

The Machine Operating System uses memory from page zero up to store operating system variables. The exact amount of RAM needed depends, for example, on whether or not the disc operating system is in use.

This call is used to return the address of the first free location in memory above that required for the operating system. In a cassette system this is normally &E00. The value is returned in X and Y with Y containing the most significant byte and X containing the least significant byte.

10A% =131

30PRINT USR(&FFF4)

>RUN

B10E0083

&0E00 is the value returned, &83 is the OSBYTE code.

OSBYTE with A=&84 (132) Read bottom of display RAM address

This call returns, in X and Y, the lowest memory address used by the screen display or by special paged ROMs. It indicates the top of free RAM that BASIC can safely use. HIMEM is normally set to this value when using the MODE statement. Its value depends, among other things, on the selected display mode and on whether the machine has 16K or 32K of RAM. As usual, Y contains the most significant byte and X the least significant byte of the result.

OSBYTE call with A=&85 (133) Read lowest address for particular MODE

This call returns, in X and Y, the address of the start of memory that would be set aside if a particular display mode were to be selected. Certain paged ROMs might also affect the value returned. The display mode to be investigated is passed in X. This call does not change modes, it merely investigates the possible consequences of changing mode.

OSBYTE call with A=&86 (134) Read text cursor position

This call returns in X and Y the X and Y co-ordinates of the text cursor. A similar function is performed in BASIC by POS and VPOS. As an OSBYTE call this takes typically 100 micro-seconds in release 1.0.

OSBYTE call with A=&87 (135) Read character at text cursor position

On exit X will contain the character at the text cursor's position and Y will contain a value representing the current graphics display mode. If the character cannot be recognised then X will contain zero.

The following function could be used to read the character at position X, Y in a BASIC program.

2000 DEF FNREADCH(X,Y)

2010 LOCAL A%,LASTX,LASTY,C

2020 LASTX=POS

2030 LASTY=VPOS

2040 VDU 31,X Y

2050 A%=135

2060 C=USR(&FFF4)

2070 C=C AND &FFFF

2080 C=C DIV &100

2090 VDU 31,LASTX,LASTY

2100 = CHR$(C)

The call is only implemented in version 1.0 and takes typically 120 micro-seconds.

OSBYTE call with A=&88 (136) Reserved

OSBYTE call with A=&89 (137) Motor control

This call is similar to the *MOTOR statement in BASIC. If only one cassette recorder is in use then setting

X=0 will turn the motor of

X=1 will turn the motor on

The cassette filing system (CFS) controls the motor using this OSBYTE call and in addition in version 1.0 it sets Y as follows

Y=0 for write operations

Y=1 for read operations.

As a result the user can easily implement a dual cassette system by trapping any OSBYTE call with A=&89 and activating (via his own hardware) the second recorder for, say, all write operations. The normal internal motor control could then be activated for all read operations.

OSBYTE call with A=&8A (138) Insert character into keyboard buffer

This call enables characters to be inserted into the keyboard buffer. On entry X=0 and Y contains the character to be inserted. Thus to place the letter "R" (ASCII code 82) into the keyboard input buffer one would use

*FX138,0,82

In machine code the X register must contain the buffer number and the Y register the character. e.g.

10 DIM GAP 20

20 OSBYTE=&FFF4

30 P%=GAP

40 [

50 LDA #138

60 LDX #0

70 LDY #82

80 JSR OSBYTE

90 RTS

100 ]

110

120 CALL GAP

>RUN

0E82

0E82 A9 SA LDA #138

0E84 A2 00 LDX #0

0E86 A0 52 LDY #82

0E88 20 F4 FF JSR OSBYTE

0E88 60 RTS

This is an extremely powerful facility! This call is only implemented from release 1.0.

OSBYTE call with A=&8B (139) File Options

This call is directly equivalent to the *OPT and it controls the computer's response to errors during file operations such as LOAD and SAVE. See page 398 for more details.

For example, with the cassette filing system *FX139,1,0

would issue no messages during file operations

*FX139,1,0 would issue no messages during file operations

*FX139,2,2 would make the computer abort if any error were detected

*FX139,3,5 would result in 0.5 second inter-block gaps

On entry X contains the option number and Y contains the particular selected option. Thus

LDA #139

LDX #1

LDY #0

JSR &FFF4

would ensure that no error messages were issued during file operations.

OSBYTE call with A=&8C (140) TAPE speed

This call is directly equivalent to *TAPE which selects the cassette file system and the baud rate to be used. On entry X contains a number to set the baud rate

X=0 default rate (1200 baud)
X=3 300 baud
X=12 1200 baud

OSBYTE call with A=&8D (141) Reserved

OSBYTE call with A=&8E (142) Reserved

OSBYTE call with A=&8F (143) Reserved

OSBYTE call with A=&90 (144) TV

This call is functionally equivalent to *TV. The contents of the X register is used to control the vertical position of the screen display. For example, setting X=2 would move the display 2 text lines up the screen. Setting X=253 would move the display L3 lines down the screen. The contents of Y should be either 0 or 1 on entry. Y=0 permits an interlaced display Y=1 causes a non-interlaced display. Note that the offset and interlace mode selected only come into effect at the next MODE change. The values set stay in force until a hard reset. Interlace cannot be turned off in MODE 7.

OSBYTE call with A=&91 (145) Get character from buffer

This call enables characters to be removed from various input buffers. On entry X indicates the buffer from which the character is to be extracted. On exit Y contains the character and C=0 if a character was successfully removed. If the buffer was empty then C will be 1. The buffer numbers are as follows

X=0 keyboard buffer
X=1 RS423 input buffer

OSBYTE calls with A=&92 to &97 Read or write to memory mapped input/output

This group of calls is used to read or write data from or to the various memory mapped input/output devices. It is vital that users use these routines rather than attempting to address devices directly. The use of these routines will ensure that programs will work whether they are executed in the input/output processor (the BBC computer), or in a second processor. If the user insists on addressing I/O ports directly (e.g. STA &FE60) then he or she will have to re-write programs when the system is expanded. Considerable effort has been expended to ensure that suitable routines are provided to enable the assembly language programmer to expand his system painlessly. Please learn to use the facilities provided!

There are three memory mapped input/output areas and these are named FRED, JIM and SHEILA. SHEILA contains all the machine's internal memory mapped devices, such as the analogue to digital converter, and should be treated with considerable respect. FRED and JIM, on the other hand, address external units connected to the 1MHz expansion bus.

Name Memory address range OSBYTE call

Read Write
FRED &FC00 - &FCFF &92(146) &93(147)
JIM &FD00 - &FDFF &94(148) &95(149)
SHEILA &FE00 - &FEFF &96(150) &97(151)

On entry to the routines A contains the OSBYTE call number and X the offset within the page. If a byte is to be written it should be in Y. The calls are not available before ROM issue 1.0.

An application note entitled "BBC Computer 1MHz bus" explains suggested memory allocations for FRED and JIM. It can be purchased from Acorn Computers. SHEILA addresses the devices with the offsets shown in the table on page 437.

The user should be aware that the computer expects to service interrupts from all except the User port on the B side of the 6522. The A side is used for the parallel printer interface. Routines are provided (such as OSBYTE and OSWORD calls, etc.), to handle these devices. The only circuit that the user should need to handle directly is the 6522 User port. Information about other ports is given for information only - not to encourage you to access the circuits directly. You would be well advised to use the numerous routines provided wherever possible. Further details about some ports is given in the section which deals with Input/Output. See page 467

SHEILA addresses (offset from &FE00)

Hex. offset Integrated Circuit Register Designation Description

Write Read
00 6845 CRTC Address register
01 6845 CRTC Register file
08 6850 ACIA Control register Status register
09 6850 ACIA Transmit data register Receive data register
10 Serial ULA Control register
20 Video ULA
21 Video ULA
30 LS161 Paged ROM I.D.

40 6522 VIA MOS Input/Output

60 6522 VIA ORB/IRB Output Register "B" Input Register "B"
61 6522 VIA ORA/IRA Output Register "A" Input Register "A"

62 6522 VIA DDRB Data Direction Register "B"
63 6522 VIA DDRA Data Direction Register "A"

64 6522 VIA T1C-L T1 Low-Order Latches T1 Low-Order Counter

65 6522 VIA T1C-H T1 High-Order Counter
66 6522 VIA T1L-L T1 Low-Order Latches

67 6522 VIA T1L-H T1 High-Order Latches
68 6522 VIA T2C-L T2 Low-Order Latches T2 Low-Order Counter

69 6522 VIA T2C-H T2 High-Order Counter
6A 6522 VIA SR Shift Register
6B 6522 VIA ACR Auxiliary Control Register
6C 6522 VIA PCR Peripheral Control Register
6D 6522 VIA IFR Interrupt Flag Register
6E 6522 VIA IER Interrupt Enable Register
6F 6522 VIA ORA/IRA Same as Reg 1 Except No "Handshake"

80 8271 FDC Command register Status register
81 8271 FDC Parameter register Result register
82 8271 FDC Reset register
83 8271 FDC Illegal Illegal
84 8271 FDC Write data Read data
A0 68B54 ADLC CR1/SR1 Control register 1 Status register 1
A1 68B54 ADLC CR2/SR2 Control register 2/3 Status register 2
A2 68B54 ADLC TxFIFO/
RxFIFO
Transmit FIFO, continue Receive FIFO
A3 68B54 ADLC TxFIFO/
RxFIFO
Transmit FIFO, terminate Receive FIFO
C0 ?PD7002 Data latch, A/D start Status
C1 ADC High byte of result
C2

A few examples will help to clarify the use of these calls.

*FX147,5,6

would write to FRED+5(&FC05) the value 6. Similarly

LDA #&97

LDX #&62

LDY #&FF

JSR &FFF4

would write &FF into location &FE62. An OSBYTE call with A=&97 will write to SHEILA. The base address of SHEILA is &FE00 and to this is added the offset in X (&62). The value written is contained in Y. The net effect is to write to the 6522 Data direction register and to cause all the PB lines to become outputs.

OSBYTE call with A=&E0(224) Cancel VDU queue

Many VDU codes expect a sequence of bytes. For example, VDU19 should be followed by 5 bytes. This call signals the VDU software to throw away the bytes that it has received so far. On entry X and Y must contain zero.

The next group of OSBYTE calls (&El to &E8) can be used to read or write status information. The calls read the current value of the status being investigated, AND the value with the contents of Y, EOR the result with the contents of X and then write the value back. If V represents the particular status in the computer then V becomes (V AND Y) EOR X. This sequence enables V to read or written to and enables any single bit, or group of bits of V, to be set, cleared or inverted.

If, on entry, X=&00 and Y=&FF the net effect will be to read the value of V into A without altering V. On the other hand if Y=&00 then the contents of X will be written into V. To set a single bit of V without altering other bits set all the bits of Y to 1 except the specified bit. Clear all the bits of X to 0 except the specified bit. For example, to set bit 0 of V to 1 use Y=&FE and X=&01.

To clear a single bit in V set all the bits of Y to 1 except the specified bit and set X=0. For example, to clear bit 0 of V use Y=&FE and X=&00. Of course, many bits may be set, cleared, inverted or examined at the same time.

OSBYTE call with A=&E1 (225) Set base number for function-key codes

Normally the red function-keys can be programmed to produce strings of characters by, for example, the statement

*KEY 0 PRINT

As an alternative the keys can produce a single ASCII code. The statement

*FX225,240

would set the base value for the function keys to 240 thus causing key "f0" to produce ASCII code 240, f1 to produce 241 and so on to f9 which would produce 249. This enables these keys to produce ASCII codes for user defined characters.

*FX 225,1 returns the keys to their normal function of generating strings.

*FX 225,0 makes the keys have no effect. On entry Y must contain zero. This facility is only available from issue 1.0.

OSBYTE call with A=&EA (228) Set base number for SHIFT-function-key codes

Pressing one of the function keys while the SHIFT key is pressed will normally in release 1.0 produce ASCII codes in the range 128 to 137. These values were chosen with the Teletext codes in mind.

Shift-function-key ASCII code Teletext effect
f0 128 nothing
f1 129 Red alphanumeric
f2 130 Green alphanumeric
f3 131 Yellow alphanumeric
f4 132 Blue alphanumeric
f5 133 Magenta alphanumeric
f6 134 Cyan alphanumeric
f7 135 White alphanumeric
f8 136 Flash
f9 137 Steady

These codes are said to have a "base value" of 128 since key f0 produces a code 128.

If the user wishes, the base value of the ASCII codes can be changed by using this call.

*FX 226,144

This would set the SHIFT-function-key codes to produce equivalent graphics-colour Teletext codes. The default setting is

*FX 226, 128.

On entry Y must contain zero.

This facility is only available from release 1.0.

OSBYTE call with A=&E3(227) Set base number for CTRL-function-key codes

See the entry for OSBYTE &E2. The default base value is 144.

OSBYTE call with A=&E4(228) Set base number for SHIFT-CTRL-function-key codes

See entry for OSBYTE &E2. The default is that these key combinations have no effect. Note: remember that pressing CTRL and SHIFT together stops output to the screen going into the next line.

OSBYTE call with A=&E5 (229) ESCAPE key gives ASCII code

This call can be used to make the ESCAPE key generate an ASCII code (27 or &1B) instead of interrupting a BASIC program. If X=0 then the ESCAPE key interrupts the BASIC program (*FX229,0). On the other hand, *FX229,1 (X=1) causes the key to generate its ASCII code. On entry Y must contain zero.

This facility is not available before issue 1.0.

OSBYTE call with A=&E6 (230) Enable/disable normal ESCAPE Key action

When a BASIC program is interrupted by pressing the ESCAPE key, or by *FX125, all internal buffers will be cleared. This call can be used to stop the flushing of all internal buffers when a program is stopped. On entry Y must contain zero.

*FX230,0 will permit all buffers to be flushed

*FX230,l will ensure that no buffers are flushed

This facility is only available from issue 1.0.

OSBYTE call with A=&E7 (231) Enable/disable user 6522 IRQ

This call sets a "mask" byte which the operating system uses when servicing IRQs which may have originated in the 6522 which is used for the parallel printer and user port. The operating system ANDs the mask byte with the 6522 Interrupt Flag Register AND the 6522 Interrupt Enable Register. Setting the mask to zero would prevent the operating system from handling the 6522 interrupts thus leaving them available to be handled by user supplied routines. Additionally "Sideways ROMs" may handle (via the operating system) interrupts generated from the B side of the 6522. The mask byte could hide those interrupts from the sideways ROMs.

In a Model A the mask byte defaults to &00 and in Model B machines the default is &FF.

This facility is only available from issue 1.0.

OSBYTE call with A=&E8 (232) Enable/disable 6850 ACIA IRQ

This call sets a "mask" byte which is used by the operating system when servicing IRQs which may have originated from the 6850 ACIA used for the RS423 and cassette interfaces. The operating system ANDs the mask byte with the 6850 status register. See the entry above (OSBYTE &E7) for further comments. The default value is &FF on both Model A and Model B.

This facility is only available from issue 1.0.

Exit: BBC Microcomputer User Guide; Kasoft Typesetting; Archer


The BBC Microcomputer User Guide was written by John Coll and edited by David Allen for the British Broadcasting Corporation.

Optical character recognition and original formatting effort by Mark Usher.

HTML version maintained by: Kade "Archer" Hansson; e-mail: archer@dialix.com.au

Last updated: Monday 12th February 2001