home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol071 / test.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1984-04-29  |  1.4 KB  |  72 lines

  1. Program bbtest; {$i+ }
  2.  
  3. { Program to illustrate the external routines BSET, RESET, and
  4.   TEST which set, reset and test the value of an individual bit
  5.   within a given byte, respectively.  The .SRC file for the 
  6.   external routines is the file BITBANG.SRC}
  7.  
  8.  
  9.  
  10.  
  11. type
  12.    byte = 0..255;
  13.  
  14. var i,j,k: integer;
  15.     x,a,b,c: byte;
  16.  
  17. procedure  bset( var x: byte; y: byte ); external;
  18. procedure reset( var x: byte; y: byte ); external;
  19. function   test(     x: byte; y: byte ): boolean; external;
  20.  
  21.  
  22. procedure show_bits;
  23.  
  24. {notice that the procedure test returns a boolean value, true if the 
  25.  bit is set (1) and false if not (0).  }
  26.  
  27. begin
  28. writeln;
  29. writeln('the binary represenation of the byte is: ');    
  30.     for x:= 7 downto 0 do write(test(a,x):6); 
  31. writeln;
  32. writeln;
  33. end;
  34.  
  35.  
  36. begin
  37. writeln( 'Bit banger test program' );
  38.    repeat
  39.  
  40.  
  41.     write( 'input decimal value for byte  ---> ' );
  42.     readln( a );
  43.     writeln;
  44.  
  45.     show_bits;
  46.  
  47.       write( 'Input number of Bit to set in byte ---> ' );
  48.       readln( b );
  49.  
  50.       bset( a, b );
  51.       writeln( 'new value of byte is: ', a);
  52.  
  53.     show_bits;
  54.  
  55.     writeln;
  56.     writeln('Will now reset that same bit. ');
  57.         reset( a, b );
  58.  
  59.        writeln('The value of the byte is now: ',a);
  60.        writeln;
  61.  
  62.     show_bits;
  63.       
  64.     write('Input number of bit to test to see if it is set ---> ');
  65.     readln(b);
  66.  
  67.       writeln( ' bit is: ', test( a, b ));
  68.    until false;
  69. end.
  70.  
  71.  
  72.