Category : Modula II Source Code
Archive   : MODULA-2.ZIP
Filename : BIOSCALL.MOD

 
Output of file : BIOSCALL.MOD contained in archive : MODULA-2.ZIP
IMPLEMENTATION MODULE Bioscall;

FROM SYSTEM IMPORT AX,BX,CX,DX,ES,SETREG,GETREG,CODE,SWI,WORD,BYTE,ADR,
ADDRESS;


(*
Translation from Bioscall.Pas to Logitech Modula-2 by
John Tal. 04/01/1986.

NOTE: Not all functions have been tested by myself.
I have tested some to make sure the conversion was
correct in it's general form, but I don't have the
time to try and test every single procedure here.
If you want to test them all then remove this note
paragraph and put your name & date you tested them
here.

Functions using Buffers for disk sector operations have been
changed to passing Buffer as an ADDRESS.

BiosPrinterStatus in the original Pascal verison is a Function
appearing to return a BYTE but did not actually do the assignment.
Hence the version here also does not do a RETURN.

BiosReadChar VAR paramaters changed from BYTE to CHAR.


Warning in Logitech Manual Page 14-8/14-9 (System Dep. Facil)

Declares

'Only constants, or variables and value paramaters which are
declared local to the procedure calling GETREG or SETREG, should
be used for the second argument.'

The use of pushBP and popBP is also recommended before and after
the SWI() instruction.


Novice Information :

General format of interfacing to the registers
(pg 14-8 System Dependent facilities)


MOV AL,03h becomes VAR al : CHAR;
BEGIN
al := CHR(03H);
SETREG(AX,al);

MOV AH,02h becomes VAR regsAX : WORD;
BEGIN
regsAX := WORD(02H*256);
SETREG(AX,regsAX);

MOV AH,04h
MOV AL,03h becomes VAR regsAX : WORD;
BEGIN
regsAX := WORD(04H*256 + 03H);
SETREG(AX,regsAX);

MOV ab,AL
MOV cd,AH becomes VAR regsAX : WORD;
BEGIN
GETREG(AX,regsAX);
ab := CARDINAL(regsAX) MOD 256;
cd := CARDINAL(regsAX) DIV 256;


*)



PROCEDURE BiosSetMode ( Mode : CARDINAL );
VAR
regsAX : WORD;
BEGIN
regsAX := WORD(Mode);
CODE(55H); (* PUSH BP *)
SETREG(AX,regsAX); (* MOV AX,mod *)
SWI(10H); (* INT 10 *)
CODE(5DH); (* POP BP *)
END BiosSetMode;

PROCEDURE BiosSetCursorType ( StartLine, EndLine : CARDINAL );
VAR
regsAX,regsCX : WORD;
BEGIN
regsCX := WORD((StartLine * 256) + EndLine);
CODE(55H);
SETREG(AX,0100H);
SETREG(CX,regsCX);
SWI(10H);
CODE(5DH);
END BiosSetCursorType;

PROCEDURE BiosSetPosition ( Page, Column, Row : CARDINAL );
VAR
regsAX,regsBX,regsDX : WORD;
BEGIN
regsBX := WORD(Page * 256);
regsDX := WORD(((Column-1)*256 + (Row-1)));
CODE(55H);
SETREG(AX,0200H);
SETREG(DX,regsDX);
SETREG(BX,regsBX);
SWI(10H);
CODE(5DH);
END BiosSetPosition;

PROCEDURE BiosReadPosition ( Page : CARDINAL; VAR Column, Row : CARDINAL );
VAR
regsAX,regsBX,regsDX : WORD;
BEGIN
regsBX := WORD(Page * 256);
CODE(55H);
SETREG(AX,0300H);
SETREG(BX,regsBX);
SWI(10H);
GETREG(DX,regsDX);
CODE(5DH);
Column := CARDINAL(regsDX) MOD 256;
Row := CARDINAL(regsDX) DIV 256;
END BiosReadPosition;

PROCEDURE BiosReadLtPen ( VAR Valid, Column, Row, RLine, PColumn : CARDINAL );
VAR
regsAX,regsBX,regsCX,regsDX : WORD;
BEGIN
CODE(55H);
SETREG(AX,0400);
SWI(10H);
GETREG(AX,regsAX);
GETREG(DX,regsDX);
GETREG(CX,regsCX);
GETREG(BX,regsBX);
CODE(5DH);

Valid := CARDINAL(regsAX) DIV 256;
Column := CARDINAL(regsDX) MOD 256;
Row := CARDINAL(regsDX) DIV 256;
RLine := CARDINAL(regsCX) DIV 256;
PColumn := CARDINAL(regsBX)
END BiosReadLtPen;

PROCEDURE BiosSetPage ( Page : CARDINAL );
VAR
regsAX : WORD;
BEGIN
CODE(55H);
regsAX := WORD(05H*256 + Page);
SETREG(AX,regsAX);
SWI(10H);
CODE(5DH);
END BiosSetPage;

PROCEDURE BiosScrollUp ( Blank, ULColumn, ULRow, BRColumn, BRRow, Attr
: CARDINAL );
VAR
regsAX,regsBX,regsCX,regsDX : WORD;
BEGIN
regsAX := WORD(06H*256 + Blank);
regsCX := WORD(ULRow*256 + ULColumn);
regsDX := WORD(BRRow*256 + BRColumn);
regsBX := WORD(Attr*256);
CODE(55H);
SETREG(AX,regsAX);
SETREG(CX,regsCX);
SETREG(DX,regsDX);
SETREG(BX,regsBX);
SWI(10H);
CODE(5DH);
END BiosScrollUp;

PROCEDURE BiosScrollDown ( Blank, ULColumn, ULRow, BRColumn, BRRow, Attr
: CARDINAL );
VAR
regsAX,regsBX,regsCX,regsDX : WORD;
BEGIN
regsAX := WORD(07H*256 + Blank);
regsCX := WORD(ULRow*256 + ULColumn);
regsDX := WORD(BRRow*256 + BRColumn);
regsBX := WORD(Attr*256);
CODE(55H);
SETREG(AX,regsAX);
SETREG(CX,regsCX);
SETREG(DX,regsDX);
SETREG(BX,regsBX);
SWI(10H);
CODE(5DH);
END BiosScrollDown;

PROCEDURE BiosReadCharAttr ( Page : CARDINAL; VAR Ch, Attr : CARDINAL );
VAR
regsAX,regsBX : WORD;
BEGIN
regsAX := WORD(08H*256);
regsBX := WORD(Page*256);
CODE(55H);
SETREG(AX,regsAX);
SETREG(BX,regsBX);
SWI(10H);
GETREG(AX,regsAX);
CODE(5DH);
Ch := CARDINAL(regsAX) MOD 256;
Attr := CARDINAL(regsAX) DIV 256;
END BiosReadCharAttr;

PROCEDURE BiosWriteCharAttr ( Page, Ch, Attr : CARDINAL );
VAR
regsAX,regsBX,regsCX : WORD;
BEGIN
regsAX := WORD(09H*256 + Ch);
regsBX := WORD(Page*256 + Attr);
regsCX := WORD(01H*256);
CODE(55H);
SETREG(AX,regsAX);
SETREG(BX,regsBX);
SETREG(CX,regsCX);
SWI(10H);
CODE(5DH);
END BiosWriteCharAttr;

PROCEDURE BiosWriteCh ( Page, Ch : CARDINAL );
VAR
regsAX,regsBX,regsCX : WORD;
BEGIN
regsAX := WORD(0AH*256 + Ch);
regsBX := WORD(Page*256);
regsCX := WORD(01H);
CODE(55H);
SETREG(AX,regsAX);
SETREG(BX,regsBX);
SETREG(CX,regsCX);
SWI(10H);
CODE(5DH);
END BiosWriteCh;

PROCEDURE BiosWriteDot ( Column, Row, Color : CARDINAL );
VAR
regsAX,regsCX,regsDX : WORD;
BEGIN
regsAX := WORD(0CH*256 + Color);
regsDX := WORD(Row);
regsCX := WORD(Column);
CODE(55H);
SETREG(AX,regsAX);
SETREG(DX,regsDX);
SETREG(CX,regsCX);
SWI(10H);
CODE(5DH);
END BiosWriteDot;

PROCEDURE BiosReadDot ( Column, Row : CARDINAL ) : CARDINAL;
VAR
regsAX,regsCX,regsDX : WORD;
BEGIN
regsAX := WORD(0DH*256);
regsDX := WORD(Row);
regsCX := WORD(Column);
CODE(55H);
SETREG(AX,regsAX);
SETREG(DX,regsDX);
SETREG(CX,regsCX);
SWI(10H);
GETREG(AX,regsAX);
CODE(5DH);
RETURN (CARDINAL(regsAX) MOD 256);
END BiosReadDot;

PROCEDURE BiosWriteTTY ( Ch : CARDINAL );
VAR
regsAX,regsBX : WORD;
BEGIN
regsAX := WORD(0EH*256 + Ch);
regsBX := WORD(01H);
CODE(55H);
SETREG(AX,regsAX);
SETREG(BX,regsBX);
SWI(10H);
CODE(5DH);
END BiosWriteTTY;

PROCEDURE BiosGetCurrent ( VAR Mode, Columns, Page : CARDINAL );
VAR
regsAX,regsBX : WORD;
BEGIN
regsAX := WORD(0FH*256);
CODE(55H);
SETREG(AX,regsAX);
SWI(10H);
GETREG(AX,regsAX);
GETREG(BX,regsBX);
CODE(5DH);
Mode := CARDINAL(regsAX) MOD 256;
Columns := CARDINAL(regsAX) DIV 256;
Page := CARDINAL(regsBX) DIV 256;
END BiosGetCurrent;

PROCEDURE BiosDiskReset;
VAR
regsAX : WORD;
BEGIN
regsAX := WORD(0H*256);
CODE(55H);
SETREG(AX,regsAX);
SWI(13H);
END BiosDiskReset;

PROCEDURE BiosDiskStatus() : CARDINAL;
VAR
regsAX : WORD;
BEGIN
regsAX := WORD(01H*256);
CODE(55H);
SETREG(AX,regsAX);
SWI(13H);
GETREG(AX,regsAX);
CODE(5DH);
RETURN (CARDINAL(regsAX) DIV 256);
END BiosDiskStatus;


PROCEDURE BiosReadSectors ( Drive, Side, Track, Sector, Count : CARDINAL;
Buffer : ADDRESS);
VAR
regsAX,regsBX,regsCX,regsDX,regsES : WORD;
BEGIN
regsDX := WORD(Side*256 + Drive);
regsCX := WORD(Track*256 + Sector);
regsAX := WORD(02H*256 + Count);
regsES := WORD(Buffer.SEGMENT);
regsBX := WORD(Buffer.OFFSET);
CODE(55H);
SETREG(DX,regsDX);
SETREG(CX,regsCX);
SETREG(AX,regsAX);
SETREG(ES,regsES);
SETREG(BX,regsBX);
SWI(13H);
CODE(5DH);
END BiosReadSectors;


PROCEDURE BiosVerifySectors ( Drive, Side, Track, Sector, Count : CARDINAL );
VAR
regsAX,regsCX,regsDX : WORD;
BEGIN
regsDX := WORD(Side*256 + Drive);
regsCX := WORD(Track*256 + Sector);
regsAX := WORD(04H*256 + Count);
CODE(55H);
SETREG(DX,regsDX);
SETREG(CX,regsCX);
SETREG(AX,regsAX);
SWI(13H);
CODE(5DH);
END BiosVerifySectors;

PROCEDURE BiosWriteSectors ( Drive, Side, Track, Sector, Count : CARDINAL;
Buffer : ADDRESS);
VAR
regsAX,regsBX,regsCX,regsDX,regsES : WORD;
BEGIN
regsDX := WORD(Side*256 + Drive);
regsCX := WORD(Track*256 + Sector);
regsAX := WORD(02H*256 + Count);
regsES := WORD(Buffer.SEGMENT);
regsBX := WORD(Buffer.OFFSET);
CODE(55H);
SETREG(DX,regsDX);
SETREG(CX,regsCX);
SETREG(AX,regsAX);
SETREG(ES,regsES);
SETREG(BX,regsBX);
SWI(13H);
CODE(5DH);
END BiosWriteSectors;

PROCEDURE BiosFormatTrack ( Drive, Side, Track, Count : CARDINAL;
Buffer : ADDRESS);
VAR
regsAX,regsBX,regsCX,regsDX,regsES : WORD;
BEGIN
regsDX := WORD(Side*256 + Drive);
regsCX := WORD(Track*256);
regsAX := WORD(05H*256 + Count);
regsES := WORD(Buffer.SEGMENT);
regsBX := WORD(Buffer.OFFSET);
CODE(55H);
SETREG(DX,regsDX);
SETREG(CX,regsCX);
SETREG(AX,regsAX);
SETREG(ES,regsES);
SETREG(BX,regsBX);
SWI(13H);
CODE(5DH);
END BiosFormatTrack;

PROCEDURE BiosReadChar ( VAR Char, Scan : CHAR );
VAR
regsAX : WORD;
BEGIN
regsAX := WORD(0H*256);
CODE(55H);
SETREG(AX,regsAX);
SWI(16H);
GETREG(AX,regsAX);
CODE(5DH);
Char := CHR(CARDINAL(regsAX) MOD 256);
Scan := CHR(CARDINAL(regsAX) DIV 256);
END BiosReadChar;

PROCEDURE BiosKeyWaiting() : BOOLEAN;
VAR
regsAX : WORD;
Flags : BITSET;
BEGIN
regsAX := WORD(01H*256);
CODE(55H);
SETREG(AX,regsAX);
SWI(16);
CODE(9CH); (* push flags onto stack *)
CODE(58H); (* pop stack (flags) to AX *)
GETREG(AX,Flags);
CODE(5DH);

IF (Flags * {6}) = {} THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END;

END BiosKeyWaiting;

PROCEDURE BiosShiftStatus() : CARDINAL;
VAR
regsAX : WORD;
BEGIN
regsAX := WORD(02H*256);
CODE(55H);
SETREG(AX,regsAX);
SWI(16H);
GETREG(AX,regsAX);
CODE(5DH);
RETURN (CARDINAL(regsAX) MOD 256);
END BiosShiftStatus;

PROCEDURE BiosPrintChar ( Port, Character : CARDINAL );
VAR
regsAX,regsDX : WORD;
BEGIN
regsAX := WORD(0H*256 + Character);
regsDX := WORD(Port);
CODE(55H);
SETREG(AX,regsAX);
SETREG(DX,regsDX);
SWI(17H);
CODE(5DH);
END BiosPrintChar;

PROCEDURE BiosPrinterInit ( Port : CARDINAL );
VAR
regsAX,regsDX : WORD;
BEGIN
regsAX := WORD(01H*256);
regsDX := WORD(Port);
CODE(55H);
SETREG(AX,regsAX);
SETREG(DX,regsDX);
SWI(17H);
CODE(5DH);
END BiosPrinterInit;

PROCEDURE BiosPrinterStatus ( Port : CARDINAL ) : BYTE;
VAR
regsAX,regsDX : WORD;
BEGIN
regsAX := WORD(02H*256);
regsDX := WORD(Port);
CODE(55H);
SETREG(AX,regsAX);
SETREG(DX,regsDX);
SWI(17H);
CODE(5DH);
END BiosPrinterStatus;

PROCEDURE BiosReset;
BEGIN
CODE(55H);
SWI(19H);
CODE(5DH);
END BiosReset;

PROCEDURE BiosPrintScreen;
BEGIN
CODE(55H);
SWI(05H);
CODE(5DH);
END BiosPrintScreen;

PROCEDURE BiosMemorySize() : CARDINAL;
VAR
regsAX : WORD;
BEGIN
CODE(55H);
SWI(12H);
GETREG(AX,regsAX);
CODE(5DH);
RETURN (CARDINAL(regsAX));
END BiosMemorySize;


END Bioscall.


  3 Responses to “Category : Modula II Source Code
Archive   : MODULA-2.ZIP
Filename : BIOSCALL.MOD

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/