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