2017-10-21 23:40:19 +00:00
|
|
|
{$optimize 7}
|
|
|
|
{---------------------------------------------------------------}
|
|
|
|
{ }
|
|
|
|
{ ORCA Code Generator Common }
|
|
|
|
{ }
|
|
|
|
{ This unit contains the command constants, types, }
|
|
|
|
{ variables and procedures used throughout the code }
|
|
|
|
{ generator, but which are not available to the compiler. }
|
|
|
|
{ }
|
|
|
|
{---------------------------------------------------------------}
|
|
|
|
{ }
|
|
|
|
{ These routines are defined in the compiler, but used from }
|
|
|
|
{ the code generator. }
|
|
|
|
{ }
|
|
|
|
{ Error - flag an error }
|
|
|
|
{ CMalloc - Clear and allocate memory from a pool. }
|
|
|
|
{ Malloc - Allocate memory from a pool. }
|
|
|
|
{ }
|
|
|
|
{---------------------------------------------------------------}
|
|
|
|
|
|
|
|
unit CGC;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
{$LibPrefix '0/obj/'}
|
|
|
|
|
|
|
|
uses CCommon, CGI;
|
|
|
|
|
2017-07-15 00:45:40 +00:00
|
|
|
{$segment 'CG'}
|
2017-10-21 23:40:19 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
{pcode code generation}
|
|
|
|
{---------------------}
|
|
|
|
realrec = record {used to convert from real to in-SANE}
|
2021-03-05 05:52:41 +00:00
|
|
|
itsReal: extended;
|
2017-10-21 23:40:19 +00:00
|
|
|
inSANE: packed array[1..10] of byte;
|
|
|
|
inCOMP: packed array[1..8] of byte;
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
2020-01-29 23:09:52 +00:00
|
|
|
{misc}
|
|
|
|
{----}
|
2016-11-28 01:11:12 +00:00
|
|
|
blkcnt: longint; {number of bytes in current segment}
|
2017-10-21 23:40:19 +00:00
|
|
|
|
|
|
|
{buffers}
|
|
|
|
{-------}
|
|
|
|
cbufflen: 0..maxcbuff; {number of bytes now in cbuff}
|
2016-11-28 01:11:12 +00:00
|
|
|
segDisp: longint; {disp in the current segment}
|
2017-10-21 23:40:19 +00:00
|
|
|
|
|
|
|
{-- Global subroutines -----------------------------------------}
|
|
|
|
|
|
|
|
procedure CnvSC (rec: realrec); extern;
|
|
|
|
|
|
|
|
{ convert a real number to SANE comp format }
|
|
|
|
{ }
|
|
|
|
{ parameters: }
|
|
|
|
{ rec - record containing the value to convert; also }
|
|
|
|
{ has space for the result }
|
|
|
|
|
|
|
|
|
|
|
|
procedure CnvSX (rec: realrec); extern;
|
|
|
|
|
|
|
|
{ convert a real number to SANE extended format }
|
|
|
|
{ }
|
|
|
|
{ parameters: }
|
|
|
|
{ rec - record containing the value to convert; also }
|
|
|
|
{ has space for the result }
|
|
|
|
|
|
|
|
|
2021-02-19 01:17:39 +00:00
|
|
|
procedure CnvXLL (var result: longlong; val: extended); extern;
|
|
|
|
|
|
|
|
{ convert a real number to long long }
|
|
|
|
{ }
|
|
|
|
{ parameters: }
|
|
|
|
{ result - longlong to hold the converted value }
|
|
|
|
{ val - the real value }
|
|
|
|
|
|
|
|
|
|
|
|
procedure CnvXULL (var result: longlong; val: extended); extern;
|
|
|
|
|
|
|
|
{ convert a real number to unsigned long long }
|
|
|
|
{ }
|
|
|
|
{ parameters: }
|
|
|
|
{ result - longlong to hold the converted value }
|
|
|
|
{ val - the real value }
|
|
|
|
|
|
|
|
|
2021-02-19 05:27:18 +00:00
|
|
|
function CnvLLX (val: longlong): extended; extern;
|
|
|
|
|
|
|
|
{ convert a long long to a real number }
|
|
|
|
{ }
|
|
|
|
{ parameters: }
|
|
|
|
{ val - the long long value }
|
|
|
|
|
|
|
|
|
|
|
|
function CnvULLX (val: longlong): extended; extern;
|
|
|
|
|
|
|
|
{ convert an unsigned long long to a real number }
|
|
|
|
{ }
|
|
|
|
{ parameters: }
|
|
|
|
{ val - the unsigned long long value }
|
|
|
|
|
|
|
|
|
2017-10-21 23:40:19 +00:00
|
|
|
procedure InitLabels; extern;
|
|
|
|
|
|
|
|
{ initialize the labels array for a procedure }
|
|
|
|
{ }
|
|
|
|
{ Note: also defined in CGI.pas }
|
2021-11-30 02:31:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
function SignBit (val: extended): integer; extern;
|
|
|
|
|
|
|
|
{ returns the sign bit of a floating-point number }
|
|
|
|
{ (0 for positive, 1 for negative) }
|
2017-10-21 23:40:19 +00:00
|
|
|
|
|
|
|
{-- These routines are defined in the compiler, but used from cg --}
|
|
|
|
|
|
|
|
function Calloc (bytes: integer): ptr; extern;
|
|
|
|
|
|
|
|
{ Allocate memory from a pool and clear it. }
|
|
|
|
{ }
|
|
|
|
{ Parameters: }
|
|
|
|
{ bytes - number of bytes to allocate }
|
|
|
|
{ ptr - points to the first byte of the allocated memory }
|
|
|
|
{ }
|
|
|
|
{ Globals: }
|
|
|
|
{ useGlobalPool - should the memory come from the global }
|
|
|
|
{ (or local) pool }
|
|
|
|
|
|
|
|
|
|
|
|
procedure Error (err: integer); extern;
|
|
|
|
|
|
|
|
{ flag an error }
|
|
|
|
{ }
|
|
|
|
{ err - error number }
|
|
|
|
|
|
|
|
|
|
|
|
{procedure Error2 (loc, err: integer); extern; {debug} {in scanner.pas}
|
|
|
|
|
|
|
|
{ flag an error }
|
|
|
|
{ }
|
|
|
|
{ loc - error location }
|
|
|
|
{ err - error number }
|
|
|
|
|
|
|
|
|
|
|
|
function Malloc (bytes: integer): ptr; extern;
|
|
|
|
|
|
|
|
{ Allocate memory from a pool. }
|
|
|
|
{ }
|
|
|
|
{ Parameters: }
|
|
|
|
{ bytes - number of bytes to allocate }
|
|
|
|
{ ptr - points to the first byte of the allocated memory }
|
|
|
|
{ }
|
|
|
|
{ Globals: }
|
|
|
|
{ useGlobalPool - should the memory come from the global }
|
|
|
|
{ (or local) pool }
|
|
|
|
|
|
|
|
{---------------------------------------------------------------}
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
end.
|
|
|
|
|
|
|
|
{$append 'CGC.asm'}
|