Simplify code for writing out extended constants.

This removes the need for the CnvSX function, so it is removed.
This commit is contained in:
Stephen Heumann 2023-04-04 18:11:04 -05:00
parent ba57d51500
commit 0b3f48157e
4 changed files with 11 additions and 56 deletions

39
CGC.asm
View File

@ -1,42 +1,6 @@
mcopy cgc.macros
****************************************************************
*
* CnvSX - Convert floating point to SANE extended
*
* Inputs:
* rec - pointer to a record
*
****************************************************************
*
CnvSX start cg
rec equ 8 record containing values
extptr equ 1 pointer to rec_ext field of rec
rec_real equ 0 disp to real (extended) value
rec_ext equ 10 disp to extended (SANE) value
pha set up DP
pha
tsc
phd
tcd
add4 rec,#rec_ext,extptr copy the number
ldy #8
lp lda [rec],y
sta [extptr],y
dey
dey
bpl lp
move4 4,8 return
pld
pla
pla
pla
pla
rtl
end
****************************************************************
*
* CnvSC - Convert floating point to SANE comp
*
* Inputs:
@ -50,8 +14,7 @@ lp lda [rec],y
CnvSC start cg
rec equ 4 record containing values
rec_real equ 0 disp to real (extended) value
rec_ext equ 10 disp to extended (SANE) value
rec_cmp equ 20 disp to comp (SANE) value
rec_cmp equ 10 disp to comp (SANE) value
tsc set up DP
phd

12
CGC.pas
View File

@ -31,9 +31,8 @@ uses CCommon, CGI;
type
{pcode code generation}
{---------------------}
realrec = record {used to convert from real to in-SANE}
realrec = record {used to convert from real to comp}
itsReal: extended;
inSANE: packed array[1..10] of byte;
inCOMP: packed array[1..8] of byte;
end;
@ -58,15 +57,6 @@ procedure CnvSC (rec: realrec); extern;
{ 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 }
procedure CnvXLL (var result: longlong; val: extended); extern;
{ convert a real number to long long }

View File

@ -357,7 +357,7 @@ procedure WriteNative (opcode: integer; mode: addressingMode; operand: integer;
label 1;
type
rkind = (k1,k2,k3,k4); {cnv record types}
rkind = (k1,k2,k3,k4,k5); {cnv record types}
var
bp: ^byte; {byte pointer}
@ -368,7 +368,8 @@ var
k1: (rval: real;);
k2: (dval: double;);
k3: (qval: longlong);
k4: (ival1,ival2,ival3,ival4: integer;);
k4: (eval: extended);
k5: (ival1,ival2,ival3,ival4,ival5: integer;);
end;
count: integer; {number of constants to repeat}
i,j,k: integer; {loop variables}
@ -666,10 +667,12 @@ case mode of
CnOut(cns.inCOMP[j]);
end;
cgExtended : begin
cns.itsReal := icptr(name)^.rval;
CnvSX(cns);
for j := 1 to 10 do
CnOut(cns.inSANE[j]);
cnv.eval := icptr(name)^.rval;
CnOut2(cnv.ival1);
CnOut2(cnv.ival2);
CnOut2(cnv.ival3);
CnOut2(cnv.ival4);
CnOut2(cnv.ival5);
end;
cgString : begin
if not icptr(name)^.isByteSeq then begin

View File

@ -310,7 +310,6 @@ type
{From CGC.pas}
realrec = record {used to convert from real to in-SANE}
itsReal: extended;
inSANE: packed array[1..10] of byte;
inCOMP: packed array[1..8] of byte;
end;