{   Computer Systems Research Group
    University of Toronto

    Module: MS-DOS BIOS Interface (IBM PC Version)   V1.01
    Author:	James R. Cordy
    Date:	9 May 1984  (Rev Dec 1985) }

{ Copyright 1984 The University of Toronto }


{ MS-DOS BIOS Device Service Routine Software Interrupt Vectors }
pervasive const CRTDSR := 10#16
pervasive const KBDSR := 16#16

{ Keyboard DSR Function Codes }
pervasive const KBREADCHAR := 00#16
pervasive const KBSTATUS := 01#16

{ CRT DSR Function Codes }
pervasive const CRTSETMODE := 00#16
pervasive const CRTSETCURTYPE := 01#16
pervasive const CRTSETCURPOSN := 02#16
pervasive const CRTREADCURPOSN := 03#16
pervasive const CRTSELECTPAGE := 05#16
pervasive const CRTSCROLLUP := 06#16
pervasive const CRTSCROLLDOWN := 07#16
pervasive const CRTREADCHARANDATTR := 08#16
pervasive const CRTWRITECHARANDATTR := 09#16
pervasive const CRTWRITECHAR := 0A#16

{ Word Registers }
pervasive const AXREG := 0
pervasive const BXREG := 1
pervasive const CXREG := 2
pervasive const DXREG := 3
pervasive const SIREG := 4
pervasive const DIREG := 5
pervasive type REGS = array AXREG .. DIREG of SignedInt

pervasive const ZEROREGS : REGS := (0,0,0,0,0,0)

{ Byte Registers }
pervasive const ALREG := 0
pervasive const AHREG := 1
pervasive const BLREG := 2
pervasive const BHREG := 3
pervasive const CLREG := 4
pervasive const CHREG := 5
pervasive const DLREG := 6
pervasive const DHREG := 7
pervasive const SILREG := 8
pervasive const SIHREG := 9
pervasive const DILREG := 10
pervasive const DIHREG := 11
pervasive type HREGS = array ALREG .. DIHREG of ShortInt

converter byteregs (REGS) returns HREGS

{ Segment Registers }
pervasive const ESREG := 0
pervasive const CSREG := 1
pervasive const SSREG := 2
pervasive const DSREG := 3
pervasive type SEGREGS = array ESREG .. DSREG of SignedInt

{ 8086 Flags }
pervasive const CFLAG := 0
pervasive const PFLAG := 2
pervasive const ACFLAG := 4
pervasive const ZFLAG := 6
pervasive const SFLAG := 7
pervasive const OFLAG := 11
pervasive type FLAGS = set of 0 .. 15

var BIOS : module
    exports (intdos, segread, intdosx, int86)

    function intdos ({var} outregs : REGS, inregs : REGS)
	returns result : FLAGS = external

    procedure segread (var seg : SEGREGS) = external

    function intdosx ({var} seg : SEGREGS, {var} outregs : REGS, inregs : REGS)
	returns result : FLAGS = external

    function int86 ({var} outregs : REGS, inregs : REGS, intno : SignedInt)
	returns result : FLAGS = external
end module
