Personal Computer News


QDOS Smooth Operations

 
Published in Personal Computer News #095

Alan Turnbull outlines some machine code utilities which help make more of QDOS operations.

Smooth Operator

Alan Turnbull outlines some machine code utilities which help make more of QDOS operations

The flow of information about QDOS, the QL operating system, has been only a trickle. As well as being handy utilities, the machine code routines given here show how to make the best use of the QDOS manual, which has done something to spread the knowledge.

The utilities fall into four categories: * A new SuperBasic procedure called BOOT which, when called like other SuperBasic procedures, attempts to 'bootstrap' the QL from Microdrive 1 as normally happens upon power-up or reset. This procedure may be used in applications programs or as an abbreviated from of the direct command LRUN mdv1 boot. * A new SuperBasic procedure called RESET which, used in applications programs, provides the facility to simulate pressing the reset button (as used in the Psion software suite). * A procedure SWITCH which allows the user to toggle between modes 4 and 8 and the QL screen from within a SuperBasic program. * An interrupt server which scans the QL keyboard 50/60 times per second and tests if Function key F3 is pressed. If so, it calls the SWITCH routine to change the screen mode. When the routine is loaded, the key F3 acts in a similar manner to CAPS LOCK. For full details, consult your QDOS manual. BOOT ---- This procedure tests whether the QL it's running on is an 'AH' or 'JM' version by reading the QDOS release number: 1.02 for 'AH'; 1.03 for lucky 'JM' owners. (Actually, there are only minor differences between releases 1.02 and 1.03 of QDOS, and they will not affect the execution of applications software.)

The routine loads the relevant 'booting' address and jumps to the ROM routine. While the QL searches Microdrive 1 for the file 'mdv1 boot', the QL screen is cleared down and the message "Attempting to boot off Microdrive 1" is displayed.

Note that what BOOT actually does is an MRUN, so make sure any program currently in the memory is either deleted by NEW before BOOT is called or is effectively deleted by the overlaying file 'mdv1_boot'. RESET ----- This fairly simple routine took some time to work out. It is no use just calling the initialisation routine from Basic with something like CALL 360 (or CALL PEEK-L(4), for the pedantic). When you do this, the Motorola MC68008 is running in user mode. To do the reset correctly, the MC68008 must be in supervisor mode.

This can be arranged by doing a TRAP #0, which discards the special QDOS return address, and then load the MC68008 Processor Status Word with the correct bit-pattern.

This Processor Status Word is arranged as two bytes: the user byte and the system byte. The user byte holds the usual, application program-related flags such as zero, overflow, carry, etc. The system byte, however, holds flags for trace mode, supervisor/user mode and the interrupt masks.

In fact, the whole Processor Status Word is arranged as follows: User byte (least significant) Bit 0: Carry Bit 1: Overflow Bit 2: Zero Bit 3: Negative Bit 4: Extend Bit 5-7: Not used System byte (most significant) Bits 0-2: Interrupt mask Bits 3-4: Not used Bit 5: Supervisor/user mode select Bit 6: Not used Bit 7: Trace mode select For a proper system reset the user byte should be set to zero and the system byte to 00100111 (binary) in order to signal supervisor mode and enable all interrupts.

This means that the 16-bit value placed in SR, the Processor Status Word, should be 0010011100000000 (binary) or 2700 (hex). SWITCH ------ This routine simply reads the current screen mode (4- or 8-colour - stored as code 0 or 8) and toggles it by 'Exclusive-OR'ing the value read with 8. This new value is then sent back to set the new screen mode. The whole operation is carried out by using the same QDOS TRAP. Interrupt Server ---------------- The addition of the 50/60 H3 interrupt-server routine to the QL's operating system provides a screen mode toggle switch, similar in function to CAPS LOCK.

The interrupt server simply examines the Function key F3 every time a screen frame is displayed to see if it is depressed. This is done by communication with the QL's secondary processor chip (IPC) - the Intel i8049. The QDOS Manual should be studied for the IPC communication command format. Adding The New Features ----------------------- You have a choice of what to do. You could assemble the Motorola format assembly listing in Listing 1, save the code generated (position independent) to a Microdrive file, say, 'mdv2_listing1', reset the QL and type in:

LET reserved_address=RESPR(256) LBYTES mdv2_listing1, reserved_address CALL reserved_address

On the other hand you could type in, save to Microdrive, reset the QL and LRUN the program in Listing 2.

Alan Turnbull