(*************************************************************************** * This sample program will sequentially turn on all bits then sequentially * turn them off. This demonstrates how to write to the card. ***************************************************************************) program sample1; uses crt; Var BASE : Word; Function Deci(DS : String) : Word; var BS : String; Er : Integer; DI : Word; begin BS := '$' + DS; Val(BS, DI, Er); Deci := DI; end; Function Hex(BB : Word) : String; var DD : String; HexTable : String; begin HexTable := '0123456789ABCDEF'; DD := '0000'; DD[4] := HexTable[(BB AND $000F) + 1]; DD[3] := HexTable[((BB AND $00F0) SHR 4) + 1]; DD[2] := HexTable[((BB AND $0F00) SHR 8) + 1]; DD[1] := HexTable[((BB AND $F000) SHR 12)+ 1]; Hex := DD; end; 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 } var ch : char; i : byte; current:word; msg:string; begin clrscr; gotoxy(12,1); writeln(' A C C E S IDO-XX C A R D S A M P L E P R O G R A M '); gotoxy(10,3); writeln(' PRESS ANY KEY TO CONTINUE. '); ch := readKey; BASE:=AskForBaseAddress('350'); gotoxy(12,1); writeln(' A C C E S IDO-XX C A R D S A M P L E P R O G R A M '); gotoxy(27,8); writeln(' PORT 0 1 AND 2 OUTPUT'); gotoxy(27,9); writeln(' ---------------------'); gotoxy(24,19); writeln(' PRESS ANY KEY TO EXIT PROGRAM '); current:=$FFFE; i:=0; while not keypressed do { loop until key pressed } begin gotoxy(36,11); write(hex(current)); portw[BASE] := current; { write value to port 0 } delay(0); portw[BASE+2]:=current; { write same value to port 1 ... } delay(0); portw[BASE+4]:=current; { ...and to port 2 } delay(0); current:=not(1 shl i); i:=i+1; i:=i mod 16; delay(1000); end; ch := readkey; { Catch the trailing keypress. } clrscr; end. (* main program *)