Acorn MOS
Encyclopedia
Acorn
Acorn Computers
Acorn Computers Ltd. was a British computer company established in Cambridge, England, in 1978. The company produced a number of computers which were especially popular in the UK. These included the Acorn Electron, the BBC Micro, and the Acorn Archimedes...

's Machine Operating System (MOS) or OS was a computer operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

 used in the Acorn BBC computer range. It included support for four-channel sound and graphics, file system abstraction, and digital and analogue I/O including a daisy-chained fast expansion bus. The implementation was single-tasking, monolithic and non re-entrant.

Versions 0.10 to 1.20 were used on the BBC Micro
BBC Micro
The BBC Microcomputer System, or BBC Micro, was a series of microcomputers and associated peripherals designed and built by Acorn Computers for the BBC Computer Literacy Project, operated by the British Broadcasting Corporation...

, version 1.00 on the Electron
Acorn Electron
The Acorn Electron is a budget version of the BBC Micro educational/home computer made by Acorn Computers Ltd. It has 32 kilobytes of RAM, and its ROM includes BBC BASIC along with its operating system....

, version 2 was used on the B+, and versions 3 to 5 were used in the BBC Master Series
BBC Master
The BBC Master was a home computer released by Acorn Computers in early 1986. It was designed and built for the British Broadcasting Corporation and was the successor to the BBC Micro Model B. The Master 128 remained in production until 1993....

 range.

The final BBC computer, the BBC A3000, was 32-bit
32-bit
The range of integer values that can be stored in 32 bits is 0 through 4,294,967,295. Hence, a processor with 32-bit memory addresses can directly access 4 GB of byte-addressable memory....

 and ran RISC OS
RISC OS
RISC OS is a computer operating system originally developed by Acorn Computers Ltd in Cambridge, England for their range of desktop computers, based on their own ARM architecture. First released in 1987, under the name Arthur, the subsequent iteration was renamed as in 1988...

. Its operating system used portions of the Acorn MOS architecture and shared a number of characteristics (commands, VDU system) with the earlier 8-bit MOS.

Versions 0 and 1 of the MOS were 16KiB
Kilobyte
The kilobyte is a multiple of the unit byte for digital information. Although the prefix kilo- means 1000, the term kilobyte and symbol KB have historically been used to refer to either 1024 bytes or 1000 bytes, dependent upon context, in the fields of computer science and information...

 in size, written in 6502
MOS Technology 6502
The MOS Technology 6502 is an 8-bit microprocessor that was designed by Chuck Peddle and Bill Mensch for MOS Technology in 1975. When it was introduced, it was the least expensive full-featured microprocessor on the market by a considerable margin, costing less than one-sixth the price of...

 machine code
Machine code
Machine code or machine language is a system of impartible instructions executed directly by a computer's central processing unit. Each instruction performs a very specific task, typically either an operation on a unit of data Machine code or machine language is a system of impartible instructions...

, and held in ROM
Read-only memory
Read-only memory is a class of storage medium used in computers and other electronic devices. Data stored in ROM cannot be modified, or can be modified only slowly or with difficulty, so it is mainly used to distribute firmware .In its strictest sense, ROM refers only...

 on the motherboard
Motherboard
In personal computers, a motherboard is the central printed circuit board in many modern computers and holds many of the crucial components of the system, providing connectors for other peripherals. The motherboard is sometimes alternatively known as the mainboard, system board, or, on Apple...

. The upper quarter of the 16-bit
16-bit
-16-bit architecture:The HP BPC, introduced in 1975, was the world's first 16-bit microprocessor. Prominent 16-bit processors include the PDP-11, Intel 8086, Intel 80286 and the WDC 65C816. The Intel 8088 was program-compatible with the Intel 8086, and was 16-bit in that its registers were 16...

 address space (0xC000 to 0xFFFF) is reserved for its ROM code and I/O space.

Versions 2 to 5 were still restricted to a 16KiB
Kilobyte
The kilobyte is a multiple of the unit byte for digital information. Although the prefix kilo- means 1000, the term kilobyte and symbol KB have historically been used to refer to either 1024 bytes or 1000 bytes, dependent upon context, in the fields of computer science and information...

 address space but managed to hold more code and hence more complex routines, partly because of the alternative 65C102
WDC 65C02
The Western Design Center WDC 65C02 microprocessor is an upgraded CMOS version of the popular NMOS-based MOS Technology 6502 8-bit CPU — the CMOS redesign being made by Bill Mensch of the Western Design Center...

 CPU with its denser instruction set
Instruction set
An instruction set, or instruction set architecture , is the part of the computer architecture related to programming, including the native data types, instructions, registers, addressing modes, memory architecture, interrupt and exception handling, and external I/O...

 plus the careful use of paging
Paging
In computer operating systems, paging is one of the memory-management schemes by which a computer can store and retrieve data from secondary storage for use in main memory. In the paging memory-management scheme, the operating system retrieves data from secondary storage in same-size blocks called...

.

User interface

The original MOS versions – 0 to 2 – did not have a user interface per se: applications were expected to forward operating system command lines to the OS on its behalf, and the BBC BASIC
BBC BASIC
BBC BASIC is a programming language, developed in 1981 as a native programming language for the MOS Technology 6502 based Acorn BBC Micro home/personal computer, mainly by Sophie Wilson. It is a version of the BASIC programming language adapted for a U.K...

 ROM
Read-only memory
Read-only memory is a class of storage medium used in computers and other electronic devices. Data stored in ROM cannot be modified, or can be modified only slowly or with difficulty, so it is mainly used to distribute firmware .In its strictest sense, ROM refers only...

 supplied with the BBC Micro is the default application used for this purpose. The BBC Micro would halt with a "Language?" error if no ROM is present that advertises to the OS an ability to provide a user interface (so-called "language ROMs"). MOS version 3 onwards did feature a simple command-line interface
Command-line interface
A command-line interface is a mechanism for interacting with a computer operating system or software by typing commands to perform specific tasks...

, normally only seen when the CMOS
CMOS
Complementary metal–oxide–semiconductor is a technology for constructing integrated circuits. CMOS technology is used in microprocessors, microcontrollers, static RAM, and other digital logic circuits...

 did not contain a setting for the default language ROM.

Application programs on ROM, and some cassette and disc-based software also, typically provide a command line, useful for working with file storage such as browsing the currently inserted disc. The OS provides the line entry facility and obeys the commands entered, but the application itself oversees running the command prompt.

Cassette and disc based software typically relies on BBC BASIC's own user interface in order to be loaded, although it is possible to configure a floppy disc to boot up without needing to have BASIC commands executed; in practice, this was rarely performed.

In BBC BASIC, OS commands are preceded with an asterisk or passed via the OSCLI keyword, to instruct BASIC to forward that command directly to the OS. This led to the asterisk being the prompt symbol for any software providing an OS command line; MOS version 3 onwards officially uses the asterisk as the command prompt symbol. When referring to an OS command, they generally include the asterisk as part of the name, for example *RUN, *CAT, *SPOOL etc, although only the part after the asterisk is the command itself.

Unrecognised commands are offered to any "service" (extension) ROMs; filing system ROMs will often check to see if a file on disc matches that name, the same most other command-line interfaces do. The operating system call OSWORD with accumulator = 0 does however offer programs single line input (with ctrl-U for clear line and the cursor copying keys enabled) with basic character filtering and line length limit.

The MOS command line interpreter features a rather unusual idea: abbreviation of commands. To save typing a dot could be used after the first few characters, such as *L. for *LOAD and *SA. for *SAVE. *RUN was abbreviated to */ alone. *CAT, the command to catalogue a cassette or disc, can be abbreviated right down to *.

Service ROMs

3rd party ROMs generally also support command abbreviation, leading to ambiguity where two service ROMs provide commands which are very similar in name but possibly different in functionality. In this case the MOS would prioritise the command from the ROM in the higher numbered ROM slot - ie 7 would take precedence over 6.

Some 3rd party suppliers would get around this by prefixing their star commands with other letters - for example Watford Electronics ROMS would have their star commands prefixed with "W" therefore making them unique.

Extension

The lower 16KiB
Kilobyte
The kilobyte is a multiple of the unit byte for digital information. Although the prefix kilo- means 1000, the term kilobyte and symbol KB have historically been used to refer to either 1024 bytes or 1000 bytes, dependent upon context, in the fields of computer science and information...

 of the read-only memory map (0x8000 to 0xBFFF) is reserved for the active Sideways
Sideways address space
The "Sideways" address space on the Acorn BBC Microcomputer and Master-series microcomputer was Acorn's bank switching implementation, providing for permanent system expansion in the days before hard disk drives or even floppy disk drives were commonplace...

 paged bank. The Sideways system on the BBC Micro allows for one ROM at a time from sockets on the motherboard (or expansion boards) to be switched into the main memory map. Software can be run from ROM this way (leaving the RAM free of user program code, for more workspace) and the OS can be extended by way of such ROMs. The most prevalent sideways ROM after BASIC is the Acorn Disc Filing System
Disc Filing System
The Disc Filing System is a computer file system developed by Acorn Computers Ltd, and introduced in 1982 for the Acorn BBC Microcomputer. It was shipped as a ROM to be inserted onto the BBC Micro's motherboard. It has an extremely limited design, and uses a flat directory structure...

 used to provide floppy disc support to the machine.

During a reset, every paged ROM is switched in and asked how much public and private workspace it needs. Each ROM is allocated a chunk of private workspace that remains allocated at all times, and a single block of public workspace, equal to the size of the largest request, is made available to the active ROM. During operation, the paged area is rapidly switched between ROMs when file system commands are issued and unrecognised commands are put to the OS.

MOS allocates a 3½KiB
Kilobyte
The kilobyte is a multiple of the unit byte for digital information. Although the prefix kilo- means 1000, the term kilobyte and symbol KB have historically been used to refer to either 1024 bytes or 1000 bytes, dependent upon context, in the fields of computer science and information...

 block of memory (0x0000 to 0x0DFF) from the bottom of the memory map for operating system and language ROM workspace. On a cassette-only machine, 0x0E00 is the start of user program memory. With OS extension ROMs fitted such as the a filing system ROM, more memory is allocated above this point; DFS ROMs generally use another 2¾KiB
Kilobyte
The kilobyte is a multiple of the unit byte for digital information. Although the prefix kilo- means 1000, the term kilobyte and symbol KB have historically been used to refer to either 1024 bytes or 1000 bytes, dependent upon context, in the fields of computer science and information...

 to cache the disc catalogue and manage random access buffers. A network filing system ROM (for Econet
Econet
Econet was Acorn's low-cost local area network system, intended for use by schools and small businesses. Econet is rumoured to be an abbreviation of Economy Network, but Acorn were always careful to stress the Greek root, oikos, meaning "house"....

) allocates another ½KiB
Kilobyte
The kilobyte is a multiple of the unit byte for digital information. Although the prefix kilo- means 1000, the term kilobyte and symbol KB have historically been used to refer to either 1024 bytes or 1000 bytes, dependent upon context, in the fields of computer science and information...

 on top of this. This is a serious problem because MOS does not support relocation of machine code, which must be run from the address at which it was assembled, so some programs which assumed a fixed start of user program memory could overwrite MOS workspace. The problem was alleviated in versions 3 to 5 by allowing ROMs to allocate workspace in an alternative RAM bank at 0xC000 to 0xDFFF which was present in Master series computers, though old ROMs could continue to allocate blocks of main memory.

The OS also maintains a vector table of all its calls which can be updated to hook
Hooking
In computer programming, the term hooking covers a range of techniques used to alter or augment the behavior of an operating system, of applications, or of other software components by intercepting function calls or messages or events passed between software components...

 any OS calls for user extension. By altering or 'hooking' these vectors, developers could substitute their own routines for those provided as defaults by the MOS.

Text, graphics, printing

The MOS permits textual output intended for the screen to be directed instead to the printer, or both at once, allowing for very trivial printing support for plain text. Graphics printing is not supported and has to be written separately.

Graphics and in general all screen output is handled in a very unusual way. The ASCII
ASCII
The American Standard Code for Information Interchange is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text...

 control characters are almost entirely given new significance under MOS: known as the "VDU drivers", they are interpreted as video control characters. VDU 30 (i.e. ASCII 30) moves the cursor to (0, 0), VDU 4 and 5 select whether text should be drawn at the graphics or text cursor, VDU 12 clears the screen and VDU 14 and 15 turn scroll lock on and off. Thus, pressing ctrl-L will clear the screen and ctrl-N will enable scroll lock. VDU 2 and 3 toggle whether screen output is echoed to the printer.

Many more control characters take parameters: one or more characters that follow are used solely for their bit value as a parameter and not as a control code. VDU 19 handles palette remap; the following five bytes represent the palette entry, the desired colour and three reserve bytes. VDU 31 locates the text cursor to the location held in the following two bytes. VDU 17 sets the text colour and 18 the graphics colour. VDU 25 uses the succeeding five bytes to move the graphics cursor and plot solid and dashed lines, dots and filled triangles, the extent of graphics in MOS 0 and 1. The first byte is the command code, followed by the x and y co-ordinates as two byte pairs.

There is a single operating system command to write a character, OSWRCH, which is responsible for all text and graphics. For example, to move the cursor to (10, 15), you could write:

LDA #31: JSR OSWRCH \ move text cursor
LDA #10: JSR OSWRCH \ x-coordinate
LDA #15: JSR OSWRCH \ y-coordinate


On the third OS call, the cursor will move. The following code would draw a line from (0, 0) to (0, +100):

LDA #25: JSR OSWRCH \ begin "PLOT" (ASCII 25) command
LDA #4: JSR OSWRCH \ command k=4, or move absolute
LDA #0: JSR OSWRCH: JSR OSWRCH: JSR OSWRCH: JSR OSWRCH
\ send (0, 0) as low, high byte pairs

LDA #25: JSR OSWRCH \ begin PLOT
LDA #1: JSR OSWRCH \ k=1 - draw relative
LDA #0: JSR OSWRCH: JSR OSWRCH \ x = 0
LDA #100: JSR OSWRCH \ y = 100 (low byte)
LDA #0: JSR OSWRCH \ high byte


In BBC BASIC you can perform the above as any of the following:

VDU 25, 4, 0; 0; 25, 4, 100; 0;

PRINT CHR$(25); CHR$(4); CHR$(0); ... etc.

PLOT 4, 0, 0: PLOT 1, 0, 100

MOVE 0, 0: DRAW 0, 100: REM absolute co-ords only!


Graphics in the Acorn MOS use a virtual graphics resolution of 1280×1024, with pixel positions mapped to the nearest equivalent pixel in the current graphics mode. Switching video resolution will not affect the shape, size or position of graphics drawn even with completely different pixel metrics in the new mode, because this is all accounted for by the OS.

Acorn MOS does provide two other OS calls that handle text output: OSNEWL and OSASCI. OSNEWL writes a line feed and carriage return to the current output stream. OSASCI forwards all characters directly to OSWRCH except for carriage return, which triggers a call to OSNEWL instead. The precise code for OSASCI and OSNEWL – five lines of 6502 assembler – is documented in the BBC Micro User Guide.

Acorn MOS implements character recognition so that text printed on screen in the system font can be selected with the arrow keys and input with the COPY key as though it was being typed. To activate screen editing the user moves the hardware cursor to the text to be read and the OS displays a second cursor in software at the original position. Pressing COPY copies one character from the hardware cursor to the software cursor and advances both, so that holding the key down copies a section of the text, the cursors wrapping around the vertical edges of the screen as necessary. If the screen scrolls during editing, the hardware cursor's position is adjusted to follow the text. The user can make changes to the text during the copy, and user-defined characters are recognised in graphics modes. Screen editing is terminated when RETURN or ESCAPE are pressed, which have their usual effects. Character recognition is made available to users in the API with a call to read the character at the current cursor position.

Sound

Sound support is done with another OS call, OSWORD, which handles a variety of tasks enumerated via a task code placed into the accumulator. All OSWORD calls bear a parameter block used to send and receive multiple data, passed into the X and Y registers. There are four buffered sound channels -- three melodic and one noise -- based on the sound chip found in the BBC Micro. There is only one waveform for melodic channels; the supported note parameters are pitch, duration, and amplitude. The amplitude parameter is normally negative; positive values select an envelope (a predefined temporal variation) to apply to the note.

Other meta parameters (passed through the channel code when using the SOUND command in BASIC) include flush (the buffer is cleared and the channel silenced before the note is played), synchronise count (as soon as the same synch count is received for that many channels, all the synchronised notes are played together), and control over the Speech system upgrade where fitted.

Other I/O and second processor support

The OS has calls to handle reading and writing to all I/O (ports and screen memory) and programmers are strongly advised to use these. The reason for this being is that when a second processor is installed, user software is run from the separate memory map on the far side of the Tube processor bus, and direct access to memory-mapped I/O registers and video memory is impossible. However, for the sake of performance, many apps including probably all assembled games write directly to main memory for I/O, and hence crash or give you a blank screen if a 6502 second processor is attached. One issue involved here is a lack of sprite support in the OS and a need to handle this manually from user code. The driver code for the Tube interface itself is not present in the MOS, usually being supplied by an external service ROM.

The MOS contains two built-in file systems: cassette and ROM - the ROM file system is quite similar to the cassette file system (try *ROM, *OPT 1 2, *CAT with a suitable ROM installed) and shares a great deal of its code.

Releases 0 and 1

Versions for the BBC Micro
BBC Micro
The BBC Microcomputer System, or BBC Micro, was a series of microcomputers and associated peripherals designed and built by Acorn Computers for the BBC Computer Literacy Project, operated by the British Broadcasting Corporation...

 family, starting at 0.10 and finishing at 1.20. Confusingly the Electron
Acorn Electron
The Acorn Electron is a budget version of the BBC Micro educational/home computer made by Acorn Computers Ltd. It has 32 kilobytes of RAM, and its ROM includes BBC BASIC along with its operating system....

 shipped with version 1.00 despite being released after the BBC Micro's version 1.20.

Release 2

This version is for the BBC Model B+, essentially the same as MOS 1.20 except with the addition of support for the sideways and shadow RAM present on the B+.

Releases 3 to 5

MOS 3 to MOS 5 shipped with the BBC Master Series
BBC Master
The BBC Master was a home computer released by Acorn Computers in early 1986. It was designed and built for the British Broadcasting Corporation and was the successor to the BBC Micro Model B. The Master 128 remained in production until 1993....

 systems, in the Master 128; Master ET; and Master Compact models respectively.

The initial release of MOS 3 expanded upon the facilities provided in MOS 2 on the B+ to support additional hardware, provide a command line facility and extend the VDU driver code with enhanced graphics plotting abilities. Two notable versions were made public: version 3.20 being the most common, and version 3.50 (although this had more functionality and bug fixes it was not 100% compatible with some popular applications software so was offered only as an optional upgrade).

MOS 4 was a stripped down version of MOS 3 intended for the similarly stripped down Master ET, and a few minor bugs fixed.

MOS 5 shipped with the Master Compact, and was much altered with some functionality removed or highly amended.

Credits

With the exception of MOS 3.50 where the space was reclaimed for more code, the area normally hidden by the input/output memory locations (0xFC00-0xFEFF inclusive) in the MOS ROM
Read-only memory
Read-only memory is a class of storage medium used in computers and other electronic devices. Data stored in ROM cannot be modified, or can be modified only slowly or with difficulty, so it is mainly used to distribute firmware .In its strictest sense, ROM refers only...

contained a list of names and credits of contributors to the system. This could be recovered by extracting the ROM chip and reading its contents out in a EPROM programmer.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK