Do not use FX2X to copy floating-point values.

This is gratuitously slow, and may also cause a loss of precision under Golden Gate (depending on the host platform).
This commit is contained in:
Stephen Heumann 2023-04-02 16:34:53 -05:00
parent c678151bde
commit 4e5e622903
2 changed files with 97 additions and 19 deletions

28
CGC.asm
View File

@ -9,27 +9,29 @@
**************************************************************** ****************************************************************
* *
CnvSX start cg CnvSX start cg
rec equ 4 record containing values 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_real equ 0 disp to real (extended) value
rec_ext equ 10 disp to extended (SANE) value rec_ext equ 10 disp to extended (SANE) value
tsc set up DP pha set up DP
pha
tsc
phd phd
tcd tcd
ph4 rec push addr of real number add4 rec,#rec_ext,extptr copy the number
clc push addr of SANE number ldy #8
lda rec lp lda [rec],y
adc #rec_ext sta [extptr],y
tax dey
lda rec+2 dey
adc #0 bpl lp
pha move4 4,8 return
phx
fx2x convert TOS to extended
move4 0,4 return
pld pld
pla pla
pla pla
pla
pla
rtl rtl
end end

View File

@ -175,12 +175,6 @@
sta 2+&op sta 2+&op
mend mend
MACRO MACRO
&LAB FX2X
&LAB PEA $0010
LDX #$090A
JSL $E10000
MEND
MACRO
&LAB FX2C &LAB FX2C
&LAB PEA $0510 &LAB PEA $0510
LDX #$090A LDX #$090A
@ -435,3 +429,85 @@
.g .g
mnote "Missing closing '}'",16 mnote "Missing closing '}'",16
mend mend
macro
&l add4 &m1,&m2,&m3
lclb &yistwo
lclc &c
&l ~setm
aif c:&m3,.a
&c amid "&m2",1,1
aif "&c"<>"#",.a
&c amid "&m1",1,1
aif "&c"="{",.a
aif "&c"="[",.a
&c amid "&m2",2,l:&m2-1
aif &c>=65536,.a
clc
~lda &m1
~op adc,&m2
~sta &m1
bcc ~&SYSCNT
~op.h inc,&m1
~&SYSCNT anop
ago .c
.a
aif c:&m3,.b
lclc &m3
&m3 setc &m1
.b
clc
~lda &m1
~op adc,&m2
~sta &m3
~lda.h &m1
~op.h adc,&m2
~sta.h &m3
.c
~restm
mend
macro
&l ~op &opc,&op
lclc &c
&c amid "&op",1,1
aif "&c"<>"{",.b
&c amid "&op",l:&op,1
aif "&c"="}",.a
mnote "Missing closing '}'",2
&op setc &op}
.a
&op amid "&op",2,l:&op-2
&op setc (&op)
.b
&l &opc &op
mend
macro
&l ~op.h &opc,&op
&l anop
lclc &c
&c amid "&op",1,1
aif "&c"="[",.b
aif "&c"<>"{",.d
&c amid "&op",l:&op,1
aif "&c"="}",.a
mnote "Missing closing '}'",2
&op setc &op}
.a
&op amid "&op",2,l:&op-2
&op setc (&op)
.b
aif &yistwo,.c
&yistwo setb 1
ldy #2
.c
&op setc "&op,y"
&opc &op
mexit
.d
aif "&c"<>"#",.e
&op amid "&op",2,l:&op-1
&op setc "#^&op"
&opc &op
mexit
.e
&opc 2+&op
mend