home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / pascal / lzw4p12.zip / HEX_IO.PAS < prev    next >
Pascal/Delphi Source File  |  1993-02-15  |  1KB  |  52 lines

  1. (*********************************************)
  2. (*                                           *)
  3. (*  This program is donated to the Public    *)
  4. (*  Domain by MarshallSoft Computing, Inc.   *)
  5. (*  It is provided as an example of the use  *)
  6. (*  of the Personal Communications Library.  *)
  7. (*                                           *)
  8. (*********************************************)
  9.  
  10. unit hex_io;
  11.  
  12. interface
  13.  
  14. Procedure WriteHexByte(Data:Byte);
  15. Procedure WriteHexWord(Data:Word);
  16. Procedure WritePointer(P:Pointer);
  17.  
  18. implementation
  19.  
  20. uses crt;
  21.  
  22. Procedure WriteHexByte(Data:Byte);
  23. const HexChars: array[0..15] of char = '0123456789ABCDEF';
  24. begin
  25.   write( HexChars[Data SHR 4] );
  26.   write( HexChars[Data AND $0F] );
  27. end;
  28.  
  29. Procedure WriteHexWord(Data:Word);
  30. begin
  31.   WriteHexByte(Data SHR 8);
  32.   WriteHexByte(Data AND $00FF)
  33. end;
  34.  
  35. Procedure WritePointer(P:Pointer);
  36. type
  37.   PtrRec = record
  38.     Ofs : Word;
  39.     Seg : Word;
  40.   end;
  41. var
  42.   TheSeg : Word;
  43.   TheOfs : Word;
  44. begin
  45.   TheSeg := PtrRec(P).Seg;
  46.   TheOfs := PtrRec(P).Ofs;
  47.   WriteHexWord(TheSeg);
  48.   write(':');
  49.   WriteHexWord(TheOfs);
  50.   writeln;
  51. end;
  52. end.