2018-02-11 03:55:24 +00:00
|
|
|
mcopy cgc.macros
|
2017-10-21 23:40:19 +00:00
|
|
|
****************************************************************
|
|
|
|
*
|
|
|
|
* CnvSX - Convert floating point to SANE extended
|
|
|
|
*
|
|
|
|
* Inputs:
|
|
|
|
* rec - pointer to a record
|
|
|
|
*
|
|
|
|
****************************************************************
|
|
|
|
*
|
2017-07-15 00:45:40 +00:00
|
|
|
CnvSX start cg
|
2017-10-21 23:40:19 +00:00
|
|
|
rec equ 4 record containing values
|
2021-03-05 05:52:41 +00:00
|
|
|
rec_real equ 0 disp to real (extended) value
|
|
|
|
rec_ext equ 10 disp to extended (SANE) value
|
2017-10-21 23:40:19 +00:00
|
|
|
|
|
|
|
tsc set up DP
|
|
|
|
phd
|
|
|
|
tcd
|
|
|
|
ph4 rec push addr of real number
|
|
|
|
clc push addr of SANE number
|
|
|
|
lda rec
|
|
|
|
adc #rec_ext
|
|
|
|
tax
|
|
|
|
lda rec+2
|
|
|
|
adc #0
|
|
|
|
pha
|
|
|
|
phx
|
2021-03-05 05:52:41 +00:00
|
|
|
fx2x convert TOS to extended
|
2017-10-21 23:40:19 +00:00
|
|
|
move4 0,4 return
|
|
|
|
pld
|
|
|
|
pla
|
|
|
|
pla
|
|
|
|
rtl
|
|
|
|
end
|
|
|
|
|
|
|
|
****************************************************************
|
|
|
|
*
|
|
|
|
* CnvSC - Convert floating point to SANE comp
|
|
|
|
*
|
|
|
|
* Inputs:
|
|
|
|
* rec - pointer to a record
|
|
|
|
*
|
2021-11-28 20:28:42 +00:00
|
|
|
* Note: This avoids calling FX2C on negative numbers,
|
|
|
|
* because it is buggy for certain values.
|
|
|
|
*
|
2017-10-21 23:40:19 +00:00
|
|
|
****************************************************************
|
|
|
|
*
|
2017-07-15 00:45:40 +00:00
|
|
|
CnvSC start cg
|
2017-10-21 23:40:19 +00:00
|
|
|
rec equ 4 record containing values
|
2021-03-05 05:52:41 +00:00
|
|
|
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
|
2017-10-21 23:40:19 +00:00
|
|
|
|
|
|
|
tsc set up DP
|
|
|
|
phd
|
|
|
|
tcd
|
2021-11-28 20:28:42 +00:00
|
|
|
ldy #rec_real+8
|
|
|
|
lda [rec],y
|
|
|
|
pha save sign of real number
|
|
|
|
and #$7fff
|
|
|
|
sta [rec],y set sign of real number to positive
|
2017-10-21 23:40:19 +00:00
|
|
|
ph4 rec push addr of real number
|
2021-03-05 05:52:41 +00:00
|
|
|
clc push addr of SANE comp number
|
2017-10-21 23:40:19 +00:00
|
|
|
lda rec
|
|
|
|
adc #rec_cmp
|
|
|
|
tax
|
|
|
|
lda rec+2
|
|
|
|
adc #0
|
|
|
|
pha
|
|
|
|
phx
|
2021-03-05 05:52:41 +00:00
|
|
|
fx2c convert TOS to SANE comp number
|
2021-11-28 20:28:42 +00:00
|
|
|
pla
|
|
|
|
bpl ret if real number was negative
|
|
|
|
ldy #rec_real+8 restore original sign of real number
|
|
|
|
sta [rec],y
|
|
|
|
sec negate the comp value
|
|
|
|
ldy #rec_cmp
|
|
|
|
ldx #0
|
|
|
|
txa
|
|
|
|
sbc [rec],y
|
|
|
|
sta [rec],y
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
txa
|
|
|
|
sbc [rec],y
|
|
|
|
sta [rec],y
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
txa
|
|
|
|
sbc [rec],y
|
|
|
|
sta [rec],y
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
txa
|
|
|
|
sbc [rec],y
|
|
|
|
sta [rec],y
|
|
|
|
ret move4 0,4 return
|
2017-10-21 23:40:19 +00:00
|
|
|
pld
|
|
|
|
pla
|
|
|
|
pla
|
|
|
|
rtl
|
|
|
|
end
|
|
|
|
|
2021-02-19 01:17:39 +00:00
|
|
|
****************************************************************
|
|
|
|
*
|
|
|
|
* procedure CnvXLL (var result: longlong; val: extended);
|
|
|
|
*
|
|
|
|
* Convert floating point to long long
|
|
|
|
*
|
|
|
|
* Inputs:
|
|
|
|
* result - longlong to hold the converted value
|
|
|
|
* val - the real value
|
|
|
|
*
|
|
|
|
****************************************************************
|
|
|
|
|
|
|
|
CnvXLL start cg
|
|
|
|
|
|
|
|
subroutine (4:result,10:val),0
|
|
|
|
|
|
|
|
pei (val+8)
|
|
|
|
pei (val+6)
|
|
|
|
pei (val+4)
|
|
|
|
pei (val+2)
|
|
|
|
pei (val)
|
|
|
|
jsl ~CnvRealLongLong
|
|
|
|
pl8 [result]
|
|
|
|
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
****************************************************************
|
|
|
|
*
|
|
|
|
* procedure CnvXULL (var result: longlong; val: extended);
|
|
|
|
*
|
|
|
|
* Convert floating point to unsigned long long
|
|
|
|
*
|
|
|
|
* Inputs:
|
|
|
|
* result - longlong to hold the converted value
|
|
|
|
* val - the real value
|
|
|
|
*
|
|
|
|
****************************************************************
|
|
|
|
|
|
|
|
CnvXULL start cg
|
|
|
|
|
|
|
|
subroutine (4:result,10:val),0
|
|
|
|
|
|
|
|
pei (val+8)
|
|
|
|
pei (val+6)
|
|
|
|
pei (val+4)
|
|
|
|
pei (val+2)
|
|
|
|
pei (val)
|
|
|
|
jsl ~CnvRealULongLong
|
|
|
|
pl8 [result]
|
|
|
|
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2021-02-19 05:27:18 +00:00
|
|
|
****************************************************************
|
|
|
|
*
|
|
|
|
* function CnvLLX (val: longlong): extended;
|
|
|
|
*
|
|
|
|
* convert a long long to a real number
|
|
|
|
*
|
|
|
|
* Inputs:
|
|
|
|
* val - the long long value
|
|
|
|
*
|
|
|
|
****************************************************************
|
|
|
|
|
|
|
|
CnvLLX start cg
|
|
|
|
|
|
|
|
subroutine (4:val),0
|
|
|
|
|
|
|
|
ph8 [val]
|
|
|
|
jsl ~CnvLongLongReal
|
|
|
|
pla
|
|
|
|
sta >rval
|
|
|
|
pla
|
|
|
|
sta >rval+2
|
|
|
|
pla
|
|
|
|
sta >rval+4
|
|
|
|
pla
|
|
|
|
sta >rval+6
|
|
|
|
pla
|
|
|
|
sta >rval+8
|
|
|
|
|
|
|
|
lla val,rval
|
|
|
|
return 4:val
|
|
|
|
|
|
|
|
rval ds 10
|
|
|
|
end
|
|
|
|
|
|
|
|
****************************************************************
|
|
|
|
*
|
|
|
|
* function CnvULLX (val: longlong): extended;
|
|
|
|
*
|
|
|
|
* convert an unsigned long long to a real number
|
|
|
|
*
|
|
|
|
* Inputs:
|
|
|
|
* val - the unsigned long long value
|
|
|
|
*
|
|
|
|
****************************************************************
|
|
|
|
|
|
|
|
CnvULLX start cg
|
|
|
|
|
|
|
|
subroutine (4:val),0
|
|
|
|
|
|
|
|
ph8 [val]
|
|
|
|
jsl ~CnvULongLongReal
|
|
|
|
pla
|
|
|
|
sta >rval
|
|
|
|
pla
|
|
|
|
sta >rval+2
|
|
|
|
pla
|
|
|
|
sta >rval+4
|
|
|
|
pla
|
|
|
|
sta >rval+6
|
|
|
|
pla
|
|
|
|
sta >rval+8
|
|
|
|
|
|
|
|
lla val,rval
|
|
|
|
return 4:val
|
|
|
|
|
|
|
|
rval ds 10
|
|
|
|
end
|
|
|
|
|
2017-07-15 00:45:40 +00:00
|
|
|
datachk off
|
2017-10-21 23:40:19 +00:00
|
|
|
****************************************************************
|
|
|
|
*
|
|
|
|
* InitLabels - initialize the labels array
|
|
|
|
*
|
|
|
|
* Outputs:
|
|
|
|
* labelTab - initialized
|
|
|
|
* intLabel - initialized
|
|
|
|
*
|
|
|
|
****************************************************************
|
|
|
|
*
|
2017-07-15 00:45:40 +00:00
|
|
|
InitLabels start cg
|
2016-11-24 03:03:04 +00:00
|
|
|
maxLabel equ 3200
|
2017-10-21 23:40:19 +00:00
|
|
|
|
|
|
|
! with labelTab[0] do begin
|
|
|
|
lda #-1 val := -1;
|
|
|
|
sta labelTab+6
|
|
|
|
sta labelTab+8
|
|
|
|
stz labelTab defined := false;
|
|
|
|
stz labelTab+2 chain := nil;
|
|
|
|
stz labelTab+4
|
|
|
|
! end; {with}
|
|
|
|
ldx #labelTab for i := 1 to maxLabel do
|
|
|
|
ldy #labelTab+10 labelTab[i] := labelTab[0];
|
|
|
|
lda #maxLabel*10-1
|
|
|
|
mvn labelTab,labelTab
|
|
|
|
stz intLabel intLabel := 0;
|
|
|
|
rtl
|
|
|
|
end
|
2021-11-30 02:31:15 +00:00
|
|
|
datachk on
|
|
|
|
|
|
|
|
****************************************************************
|
|
|
|
*
|
|
|
|
* function SignBit (val: extended): integer;
|
|
|
|
*
|
|
|
|
* returns the sign bit of a floating-point number
|
|
|
|
* (0 for positive, 1 for negative)
|
|
|
|
*
|
|
|
|
****************************************************************
|
|
|
|
*
|
|
|
|
SignBit start cg
|
|
|
|
|
|
|
|
subroutine (10:val),0
|
|
|
|
|
|
|
|
asl val+8
|
|
|
|
stz val
|
|
|
|
rol val
|
|
|
|
|
|
|
|
return 2:val
|
|
|
|
end
|