{ ****************************************************************************** Pascal Language Sample #2 : SAMPLE2.PAS This program will display the status of each bit in the status register and displays the temperature inside your computer. Last Modified On: 2/11/98 ****************************************************************************** } Uses Crt; Var Ch : Char; CurBit : Byte; BASE: WORD; function AskForBaseAddress(OldOne : String) : Word; const Msg : string[4] = '0'; var NewOne, Success, Dummy, Error : Word; AddrInputPosX, AddrInputPosY : Word; begin if (OldOne = 'OLD') then OldOne := Msg; WriteLn('Please enter the Base Address (0000-FFFF) for your card (in hex)'); WriteLn('or press ENTER for ', OldOne, '. '); Write('>'); AddrInputPosX := WhereX; AddrInputPosY := WhereY; repeat GotoXY(AddrInputPosX, AddrInputPosY); ClrEol; Readln(Msg); Val('$' + Msg, NewOne, Error); if (error=0) then begin Success := 1; Dummy := NewOne; end else if (Msg = '') then begin GotoXY(AddrInputPosX, AddrInputPosY); WriteLn(OldOne); Msg := OldOne; Success := 1; Val('$' + Msg, Dummy, Error); end; until (Success = 1); AskForBaseAddress := Dummy; end; { end of AskForBaseAddress } Begin clrscr; BASE := AskForBaseAddress('$350'); clrscr; writeln('Pascal Sample #2: Reading Control Register and Temperature'); writeln('This program demonstrates how to read the Control Register and'); writeln('Temperature at BASE+4 and BASE+5, respectively.'); writeln('Please note that some functions require options to be installed.'); writeln('A keystroke will stop the program.'); writeln; writeln('Press any key to start.'); ch := readkey; { Grab keystroke. } clrscr; writeln(' Status Control Register Values '); writeln(' '); writeln(' Bit Number Value Description '); writeln(' 0 1 When 0, CTR1 has timed out '); writeln(' 1 1 When 0, temperature is too high OPTION 2'); writeln(' 2 1 Isolated digital input #0 OPTION 4'); writeln(' 3 1 Isolated digital input #1 OPTION 4'); writeln(' 4 0 When 0, Speed of fan is correct OPTION 4'); writeln(' 5 1 When 0, the Voltage is too high OPTION 1'); writeln(' 6 1 When 0, the Voltage is too low OPTION 1'); writeln(' 7 1 When 0, an INT has occured '); writeln(''); writeln(' Temperature inside computer is 000.0øF. OPTION 3 (=187.0 if not installed)'); writeln(' Press any key to exit this program... '); Repeat For CurBit := 0 To 7 Do Begin GotoXY(19, 4 + CurBit); { Go to correct line } Write(Ord((Port[BASE+4] AND (1 SHL CurBit)) = (1 SHL CurBit))); { check bit } End; GotoXY(34, 13); Write((((Port[BASE+5] * (11/15))) + 7):5:1); { Temperature is simply ((BASE+5) * 11/15) + 7} Until KeyPressed; writeln; End.