Back to assignment page


                               VIEJO 20
                          SYSTEM BIOS CALLS

Section 1. Introduction
---------------------------------------------------------------------
The Viejo 20 system BIOS provides a number of useful functions that obviate the
need for application programs to program most hardware directly.  System calls
may be issued by using the SYSC instruction of the A5800 CPU, and parameters
and return values to/from the system call are passed in the general-purpose and
pointer registers.  A brief command listing is given here; for more detailed
descriptions of each command, see the appropriate section:

    Number    Description
    ------------------------------------------------------
    0x00      Reset system
    0x01      Set interrupt vector
    0x02      Get interrupt vector
    0x03      Set timeout for PIT
    0x04      Get memory size
    0x05      Get system features
    0x06      Get serial port status
    0x07      Send byte to serial port
    0x08      Read byte from serial port
    0x09      Get floppy drive status
    0x0A      Recalibrate floppy drive
    0x0B      Seek floppy drive's head
    0x0C      Read sector from floppy drive
    0x0D      Write sector to floppy drive
    0x0E      Format track on floppy drive
    0x10      Get memory bank mask
    0x11      Set memory bank mask
    0x12      Get memory bank
    0x13      Set memory bank

Section 2. System call details
---------------------------------------------------------------------
Function numbers for system calls are passed in the AL register.  For example,
to reset the system, the following instruction sequence could be used:

    MOVE    AL,0x00
    SYSC

Other registers are used to pass the remainder of the parameters.

Section 2.1. Function 0x00: Reset system
This function call resets the system.

    In:  AL=0x00

    Out: (none)

Section 2.2. Function 0x01: Set interrupt vector
Sets the interrupt vector to point to the given address.

    In:  AL=0x01
         AH=vector number
         PA=handler address

    Out: PA=address of previous handler

Section 2.3. Function 0x02: Get interrupt vector

    In:  AL=0x02
         AH=vector number

    Out: PA=handler address

Section 2.4. Function 0x03: Set timeout for PIT
Sets the value of the PIT's counter.  When this counter expires, hardware
interrupt 0 will be generated, calling vector 0x10.

    In:  AL=0x03
          B=count

    Out: (none)

Section 2.5. Function 0x04: Get memory size
Gets the amount of system RAM detected by the BIOS at startup.  This includes
RAM on other banks.

    In:  AL=0x04

    Out:  A=KB of system RAM

Section 2.6. Function 0x05: Get system features
Gets the system feature set bits detected by the BIOS at startup.

    In:  AL=0x05

    Out: AL=system feature bits:

            +-----+---------------------------------------+
            | Bit | Description                           |
            +-----+---------------------------------------+
            |  0  | 1=A5801 math coprocessor present      |
            |  1  | 1=system supports 2 or 4 banks        |
            |  2  | 1=system supports 3 or 4 banks        |
            |  3  | 1=second floppy disk drive present    |
            |  4  | 1=second serial interface present     |
            |  5  | 1=second interrupt controller present |
            | 6,7 | Reserved                              |
            +-----+---------------------------------------+

Section 2.7. Function 0x06: Get serial port status
Gets the status of the serial port indicated.

    In:  AL=0x06
         AH=serial port number (0 or 1)

    Out: AL=port status bits:

            +-----+---------------------------------------------+
            | Bit | Description                                 |
            +-----+---------------------------------------------+
            |  0  | 1=port present                              |
            |  1  | 1=remote terminal ready                     |
            |  2  | 1=ready to send                             |
            |  3  | 1=a byte has been received and is available |
            | 4-7 | Reserved                                    |
            +-----+---------------------------------------------+

Section 2.8. Function 0x07: Send byte to serial port
Sends a single byte to the serial port indicated.

    In:  AL=0x07
         AH=serial port number (0 or 1)
         BL=byte to send

    Out: FL.CF set if there was an error sending the byte.
            In this case,
            AL=error code:
                0x01    Serial port not present
                0x02    Remote terminal not ready
                0x03    CTS timeout
                0x04    Transmission error

Section 2.9. Function 0x08: Receive byte from serial port
Receives a single byte from the serial port indicated.

    In:  AL=0x08
         AH=serial port number (0 or 1)

    Out: FL.CF set if there was an error sending the byte.
            In this case,
            AL=error code:
                0x01    Serial port not present
                0x02    Remote terminal not ready
                0x03    Receive timeout
                0x04    Transmission error
         Otherwise,
            AL=data byte read

Section 2.10. Function 0x09: Get floppy drive status
Checks the status of the indicated floppy disk drive.

    In:  AL=0x09
         AH=drive number (0 or 1)

    Out: AL=status byte

            +-----+---------------------------------------------+
            | Bit | Description                                 |
            +-----+---------------------------------------------+
            |  0  | 1=drive present                             |
            |  1  | 1=medium present                            |
            |  2  | 1=medium write-protected                    |
            |  3  | 1=controller busy                           |
            | 4-7 | Reserved                                    |
            +-----+---------------------------------------------+

Section 2.11. Function 0x0A: Recalibrate floppy drive
Causes the floppy drive to seek the head to track 0.

    In:  AL=0x0A
         AH=drive number (0 or 1)

    Out: FL.CF set if there was an error.
            In this case,
            AL=error code:
                0x01    Drive not present
                0x02    Medium not present
                0x03    Seek error
                0x04    Drive error

Section 2.12. Function 0x0B: Seek floppy drive's head
Causes the floppy drive to seek the head to the given track.

    In:  AL=0x0B
         AH=drive number (0 or 1)
         BL=track number (0 to 39)

    Out: FL.CF set if there was an error.
            In this case,
            AL=error code:
                0x00    Invalid parameters
                0x01    Drive not present
                0x02    Medium not present
                0x03    Seek error
                0x04    Drive error

Section 2.13. Function 0x0C: Read sector from floppy drive
Reads a sector from the floppy drive.

    In:  AL=0x0C
         AH=drive number (0 or 1)
         BL=track number (0 to 39)
         BH=sector number (0 to 8)
         CL=head number (0 or 1)
         PA=base address of 512-byte buffer for sector data

    Out: FL.CF set if there was an error.
            In this case,
            AL=error code:
                0x00    Invalid parameters
                0x01    Drive not present
                0x02    Medium not present
                0x03    Seek error
                0x04    Drive error
                0x05    Data error
         Otherwise, the buffer at PA contains 512 bytes of sector data.

Section 2.14. Function 0x0D: Write sector to floppy drive
Writes a sector to the floppy drive.

    In:  AL=0x0D
         AH=drive number (0 or 1)
         BL=track number (0 to 39)
         BH=sector number (0 to 8)
         CL=head number (0 or 1)
         PA=base address of 512-byte buffer containing sector data

    Out: FL.CF set if there was an error.
            In this case,
            AL=error code:
                0x00    Invalid parameters
                0x01    Drive not present
                0x02    Medium not present
                0x03    Seek error
                0x04    Drive error

Section 2.15. Function 0x0E: Format track on floppy drive
Formats a track on the floppy drive.

    In:  AL=0x0D
         AH=drive number (0 or 1)
         BL=track number (0 to 39)

    Out: FL.CF set if there was an error.
            In this case,
            AL=error code:
                0x00    Invalid parameters
                0x01    Drive not present
                0x02    Medium not present
                0x03    Seek error
                0x04    Drive error

Section 2.16. Function 0x10: Get memory bank mask
This function is only present on banked systems.

Gets the memory bank mask, which controls the mapping between addresses and
banks.

    In:  AL=0x10

    Out: FL.CF set if the system does not support banking.
         Otherwise,
            AL=bank mask
                Bit 0: Enable banking 0x0000-0x0FFF
                Bit 1: Enable banking 0x1000-0x1FFF
                Bit 2: Enable banking 0x2000-0x2FFF
                Bit 3: Enable banking 0x3000-0x3FFF
                Bit 4: Enable banking 0x4000-0x5FFF
                Bit 5: Enable banking 0x6000-0x7FFF
                Bit 6: Enable banking 0x8000-0x9FFF
                Bit 7: Enable banking 0xA000-0xBFFF

Section 2.17. Function 0x11: Set memory bank mask
This function is only present on banked systems.

Sets the memory bank mask, which controls mapping between addresses and banks.

    In:  AL=0x11
         AH=bank mask
            Bit 0: Enable banking 0x0000-0x0FFF
            Bit 1: Enable banking 0x1000-0x1FFF
            Bit 2: Enable banking 0x2000-0x2FFF
            Bit 3: Enable banking 0x3000-0x3FFF
            Bit 4: Enable banking 0x4000-0x5FFF
            Bit 5: Enable banking 0x6000-0x7FFF
            Bit 6: Enable banking 0x8000-0x9FFF
            Bit 7: Enable banking 0xA000-0xBFFF

    Out: FL.CF set if the system does not support banking.

Section 2.18. Function 0x12: Get memory bank
This function is only present on banked systems.

Gets the current memory bank.  This bank is used for accesses to all memory
addresses where the bank mask has enabled banking; bank 0 is used for all other
accesses.

    In:  AL=0x12

    Out: FL.CF set if the system does not support banking.
         Otherwise,
            AL=bank number (0 to 3)

Section 2.19. Function 0x13: Set memory bank
This function is only present on banked systems.

Sets the current memory bank.  This bank is used for accesses to all memory
addresses where the bank mask has enabled banking; bank 0 is used for all other
addresses.

    In:  AL=0x13
         AH=bank number (0 to 3)

    Out: FL.CF set if the system does not support banking, or if an invalid
            bank number was selected.