Lets give more flexibility in working with the float stack in Forth.
the entry point listed in the new words..
Code:
=OX EQU #2FBD0 X address
Code:
* X<> exchange the value in the variable with the value in X like the HP41 command
* use: FVAR1 X<> tested 15july2024
WORD 'X<>'
P= 0
LC(5) =OX put X-address into C(A)
CD0EX exchange data pointer address D0 with C(A)
R2=C save D0
A=DAT0 W A = value of X from its address in C(A)
R0=A R0 = X
C=DAT1 A copy data at address in D1 into C(A)
CD0EX
A=DAT0 W copy data at address in D0 (in C(A)) into W in A
R1=A R1 = Reg value
P= 0
LC(5) =OX put X-address into C(A)
CD0EX exchange data pointer address D0 with C(A)
A=R1
DAT0=A W X has now value of Reg
C=DAT1 A copy data at address in D1 into C(A)
CD0EX exchange C(A) with D0
A=R0
DAT0=A W value of X into reg
C=R2
D0=C restore D0
D1=D1+ 5 return nothing on data stack
RTNCC
Code:
* X<>Z exchange the HP41 registers. tested 12 July 2024
WORD 'X<>Z'
P= 0
LC(5) =OX put X-address into field A of register C
* low order 5 nibbles
CD0EX put data pointer D0 into C(A)
R1=C save D0 into R1
C=DAT0 W C = value of X (which is in D0)
D0=D0+ 16 D0 has now Y addr
D0=D0+ 16 D0 has now Z addr
A=DAT0 W put value of Z into A via addr in D0
DAT0=C W Z = value of X
D0=D0- 16
D0=D0- 16 D0 -> X
DAT0=A W X = value of Z
C=R1
D0=C restore D0
RTNCC
Code:
* X<>T exchange the HP41 registers, tested 12 July 2024
WORD 'X<>T'
P= 0
LC(5) =OX put X-address into field A of register C
* low order 5 nibbles
CD0EX put data pointer D0 into C(A)
R1=C save D0 into R1
C=DAT0 W C = value of X
D0=D0+ 16 D0 -> Y
D0=D0+ 16 D0 -> Z
D0=D0+ 16 D0--> T
A=DAT0 W put value of T into A
DAT0=C W T = value of X
D0=D0- 16
D0=D0- 16
D0=D0- 16 D0 -> X
DAT0=A W X = value of T
C=R1
D0=C restore D0
RTNCC
Code:
* X<>L exchange the HP41 registers, tested 12 July 2024
WORD 'X<>L'
P= 0
LC(5) =OX put X-address into field A of register C
* low order 5 nibbles
CD0EX put data pointer D0 into C(A)
R1=C save D0 into R1
C=DAT0 W C = value of X
D0=D0- 16 D0--> L
A=DAT0 W put value of L into A
DAT0=C W L = value of X
D0=D0+ 16 D0 -> X
DAT0=A W X = value of L
C=R1
D0=C restore D0(A) from C(A)
RTNCC
More words needed like example Z<>L ?
this word is
X<>Z
X<>L
X<>Z
therefore Z<>L could be a new Forth word (lower need since this is a combination of the 3 above new words).
As usual, remarks are welcomed.