~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to utils/simulator/simbase.pas

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{
2
 
    $Id: simbase.pas,v 1.2 2002/09/07 15:40:37 peter Exp $
3
 
    This file is part of the Free Pascal simulator environment
4
 
    Copyright (c) 1999-2000 by Florian Klaempfl
5
 
 
6
 
    This unit implemements some helper routines
7
 
 
8
 
    See the file COPYING.FPC, included in this distribution,
9
 
    for details about the copyright.
10
 
 
11
 
    This program is distributed in the hope that it will be useful,
12
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 
 
15
 
 **********************************************************************}
16
 
{$N+}
17
 
{$H-}
18
 
unit simbase;
19
 
 
20
 
  interface
21
 
{$ifdef Delphi}
22
 
    uses
23
 
       dmisc;
24
 
{$else Delphi}
25
 
    uses
26
 
       dos;
27
 
{$endif Delphi}
28
 
 
29
 
    { global types }
30
 
    type
31
 
       { tindex must be at least of type integer }
32
 
       tindex = integer;
33
 
{$ifndef FPC}
34
 
       int64 = comp;
35
 
       qword = comp;
36
 
{$endif FPC}
37
 
       dword = longint;
38
 
       tdword = array[0..3] of byte;
39
 
 
40
 
       pbyte = ^byte;
41
 
       pword = ^word;
42
 
       pdword = ^dword;
43
 
       pqword = ^qword;
44
 
 
45
 
       tqwordrec = record
46
 
          case tindex of
47
 
             1 : (low32,high32 : dword);
48
 
             2 : (bytes : array[0..7] of byte);
49
 
             3 : (words : array[0..3] of word);
50
 
       end;
51
 
 
52
 
       oword = array[0..7] of word;
53
 
 
54
 
       towordrec = record
55
 
          case tindex of
56
 
             1 : (bytes : array[0..15] of byte);
57
 
             2 : (words : array[0..7] of word);
58
 
             3 : (low64,high64 : qword);
59
 
       end;
60
 
 
61
 
    function hexstr(val : longint;cnt : byte) : string;
62
 
    function qword2str(q : qword) : string;
63
 
    function realtime : double;
64
 
 
65
 
    var
66
 
       stopsim : procedure;
67
 
 
68
 
  implementation
69
 
 
70
 
    function hexstr(val : longint;cnt : byte) : string;
71
 
 
72
 
       const
73
 
          HexTbl : array[0..15] of char='0123456789ABCDEF';
74
 
 
75
 
       var
76
 
         i : tindex;
77
 
 
78
 
       begin
79
 
          hexstr[0]:=char(cnt);
80
 
          for i:=cnt downto 1 do
81
 
            begin
82
 
               hexstr[i]:=hextbl[val and $f];
83
 
               val:=val shr 4;
84
 
            end;
85
 
       end;
86
 
 
87
 
    function qword2str(q : qword) : string;
88
 
 
89
 
      begin
90
 
         qword2str:=hexstr(tqwordrec(q).high32,8)+hexstr(tqwordrec(q).low32,8);
91
 
      end;
92
 
 
93
 
    function realtime : double;
94
 
 
95
 
      var
96
 
         h,m,s,s100 : word;
97
 
 
98
 
      begin
99
 
         gettime(h,m,s,s100);
100
 
         realtime:=h*3600+m*60+s+s100/100.0;
101
 
      end;
102
 
 
103
 
    procedure _stopsim;{$ifdef TP}far;{$endif TP}
104
 
 
105
 
      begin
106
 
         writeln('Simulation stopped');
107
 
         halt(1);
108
 
      end;
109
 
 
110
 
begin
111
 
   {$ifdef FPC}
112
 
   stopsim:=@_stopsim;
113
 
   {$else FPC}
114
 
   stopsim:=_stopsim;
115
 
   {$endif FPC}
116
 
end.
117
 
{
118
 
  $Log: simbase.pas,v $
119
 
  Revision 1.2  2002/09/07 15:40:37  peter
120
 
    * old logs removed and tabs fixed
121
 
 
122
 
}