to push and pop from the floating point stack to/from the returnstack. A significant reason for suggesting the F>R FR> pair is to deal
In a corpus of about 8000 iForth files, "FROT FSWAP" appears 9 times:
Searching for: FROT FSWAP
D:dfwforthincludecomplex.frt(231): : X- FROT FSWAP F- <i1> <r1> <i2>
<r2> --- <i3> <r3>
D:dfwforthincludecplx_fsl.frt(175): FROT FSWAP F- -FROT D:dfwforthincludecplx_fsl.frt(210): FROT FSWAP FOVER F* D:dfwforthincludefft.frt(66): : X- FROT FSWAP F- -FROT F- FSWAP ; PRIVATE
D:dfwforthincludemiscutil.frt(1761): FROT FSWAP F- -FROT F- FSWAP ; D:dfwforthincludepcylfun.frt(259): FROT FSWAP FOVER F+ D:dfwforthincludepcylfun.frt(270): FROT FSWAP FOVER F+ D:dfwforthexamplesgraphicshenon.frt(71): y{ 0 1 :: }range[] FROT FSWAP SET-GWINDOW
D:dfwforthexamplesgraphicskrawczyk.frt(127): y{ 0 1 :: }range[] FROT
FSWAP SET-GWINDOW
0 RISE \ same as SWAP
1 RISE \ i*x a b c -- i*x b a c
2 RISE \ i*x a b c d -- i*x b a c d
Krishna Myneni <krishna.myneni@ccreweb.org> writes:
0 RISE \ same as SWAP
1 RISE \ i*x a b c -- i*x b a c
2 RISE \ i*x a b c d -- i*x b a c d
Speaking entirely as a wholly inexpert Forth aficionado, I like both the
name 'RISE' and function a lot.
I'm in need of a convenient way to do the following for the fp stack,
but we can pose the problem for the data stack:
a b c -- b a c
Two ways to do this on the data stack are
ROT SWAP
>R SWAP R>
( the latter can't be done from the interpreter, portably at least ).
I'm in need of a convenient way to do the following for the fp stack,
but we can pose the problem for the data stack:
a b c -- b a c
Two ways to do this on the data stack are
ROT SWAP
>R SWAP R>
( the latter can't be done from the interpreter, portably at least ).
Is there a word I'm not remembering to perform this operation? If not
what name would one give to this stack operation?
SWAP-UNDER
ROTSWAP
RISE
For fp stack manipulation, I had posted mostly portable code for F>R and
to push and pop from the floating point stack to/from the returnstack. A significant reason for suggesting the F>R FR> pair is to deal
with this situation where having to use FROT FSWAP would be inefficient
on non-analytic compilers.
Maybe a generic swap operation at depth u, called RISE, is useful e.g.
0 RISE \ same as SWAP
1 RISE \ i*x a b c -- i*x b a c
2 RISE \ i*x a b c d -- i*x b a c d
etc.
Comments?
--
Krishna Myneni
In 8th there's "_swap" which does "a b c -- b a c"
I'm in need of a convenient way to do the following for the fp stack,
but we can pose the problem for the data stack:
a b c -- b a c
Two ways to do this on the data stack are
ROT SWAP
>R SWAP R>
( the latter can't be done from the interpreter, portably at least ).
Is there a word I'm not remembering to perform this operation? If not
what name would one give to this stack operation?
SWAP-UNDER
ROTSWAP
RISE
For fp stack manipulation, I had posted mostly portable code for F>R and
to push and pop from the floating point stack to/from the returnstack. A significant reason for suggesting the F>R FR> pair is to deal
with this situation where having to use FROT FSWAP would be inefficient
on non-analytic compilers.
Maybe a generic swap operation at depth u, called RISE, is useful e.g.
0 RISE \ same as SWAP
1 RISE \ i*x a b c -- i*x b a c
2 RISE \ i*x a b c d -- i*x b a c d
etc.
Comments?
--
Krishna Myneni
On 1/12/2023 9:04 pm, albert wrote:[..]
In article <ukalqa$1fmfg$1@dont-email.me>,
Krishna Myneni <krishna.myneni@ccreweb.org> wrote:
I'm in need of a convenient way to do the following for the fp stack,
but we can pose the problem for the data stack:
The presence of ROT SWAP ought to raise a red flag as it suggests
something is awry. After examining the code we may conclude its
use in this case was the least worst option.
On 30/11/2023 6:55 pm, Krishna Myneni wrote:
I'm in need of a convenient way to do the following for the fp stack,
but we can pose the problem for the data stack:
a b c -- b a c
Two ways to do this on the data stack are
ROT SWAP
>R SWAP R>
( the latter can't be done from the interpreter, portably at least ).
Is there a word I'm not remembering to perform this operation? If not
what name would one give to this stack operation?
SWAP-UNDER
ROTSWAP
RISE
For fp stack manipulation, I had posted mostly portable code for F>R
and FR> to push and pop from the floating point stack to/from the
return stack. A significant reason for suggesting the F>R FR> pair is
to deal with this situation where having to use FROT FSWAP would be
inefficient on non-analytic compilers.
Maybe a generic swap operation at depth u, called RISE, is useful e.g.
0 RISE \ same as SWAP
1 RISE \ i*x a b c -- i*x b a c
2 RISE \ i*x a b c d -- i*x b a c d
etc.
Comments?
--
Krishna Myneni
Since no one suggested it, in factor they have called it swapd ( x y z
-- y x z )
https://docs.factorcode.org/content/word-swapd%2Ckernel.html
Using the same convention you could call it fswapd for operating on the floating stack.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (2 / 14) |
Uptime: | 35:32:36 |
Calls: | 6,707 |
Files: | 12,239 |
Messages: | 5,353,387 |