• Multiplicate a variable by number with (not) moving the stack

    From pascal dagornet@21:1/5 to All on Tue May 23 00:46:48 2023
    Hello,
    I am starting FORTH for a small non commercial project and perhaps somebody here could support a bit?

    For multiplication by 2 of a variable R, I made

    R F@
    2.0e
    F*
    R F!

    Is there any method to not make moving the stack?

    Word "F2*" would multiplicate the value of R by 2 direct in address..
    "R F2*"

    Or Word "FX*" would multiplicate the value of R by X direct in address.. (in this case the stack would move only by 1 level which would be ok for me)
    "1.234e FX* R"

    Any advice / hint how to design the words F2* or FX* is welcome.

    Regards.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From jan Coombs@21:1/5 to pascal dagornet on Tue May 23 11:55:30 2023
    On Tue, 23 May 2023 00:46:48 -0700 (PDT)
    pascal dagornet <pascaldagornet@gmail.com> wrote:

    Hello,
    I am starting FORTH for a small non commercial project and perhaps somebody here could support a bit?

    For multiplication by 2 of a variable R, I made

    R F@
    2.0e
    F*
    R F!

    Is there any method to not make moving the stack?


    $ gforth
    Gforth 0.7.3, Copyright (C) 1995-2008 Free Software Foundation, Inc.
    Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
    Type `bye' to exit

    0x10000000000000 constant Flt64b_ExpLSBmask


    : InMemF2* ( addr -- ) \ mutiply float at addr by two
    \ Note: 64b IEE-754 float format
    \ Subnormals not handled
    \ Float length is same as integer
    dup @ Flt64b_ExpLSBmask + swap ! ;


    variable f01 ok
    variable f02 ok

    : test_InMemF2* ( -- ) ( F f -- ) \
    fdup f01 f! f02 f! f02 InMemF2* cr f01 f@ f. f02 f@ f. ;

    5e0 test_InMemF2*
    5. 10. ok

    123.125e0 test_InMemF2*
    123.125 246.25 ok


    Jan Coombs
    --

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marcel Hendrix@21:1/5 to pascal dagornet on Tue May 23 03:17:20 2023
    On Tuesday, May 23, 2023 at 9:46:49 AM UTC+2, pascal dagornet wrote:
    For multiplication by 2 of a variable R, I made

    R F@
    2.0e
    F*
    R F!

    Is there any method to not make moving the stack?

    fdup f+

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to pascal dagornet on Tue May 23 14:26:41 2023
    pascal dagornet schrieb am Dienstag, 23. Mai 2023 um 09:46:49 UTC+2:
    Hello,
    I am starting FORTH for a small non commercial project and perhaps somebody here could support a bit?

    For multiplication by 2 of a variable R, I made

    R F@
    2.0e
    F*
    R F!

    Is there any method to not make moving the stack?

    Word "F2*" would multiplicate the value of R by 2 direct in address..
    "R F2*"

    Or Word "FX*" would multiplicate the value of R by X direct in address.. (in this case the stack would move only by 1 level which would be ok for me)
    "1.234e FX* R"

    Any advice / hint how to design the words F2* or FX* is welcome.


    Why is it necessary to not move the stack?

    Somewhat simpler: make F an FVALUE instead of an FVARIABLE, then do
    F +TO F

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dxforth@21:1/5 to minforth on Wed May 24 11:06:13 2023
    On 24/05/2023 7:26 am, minforth wrote:
    pascal dagornet schrieb am Dienstag, 23. Mai 2023 um 09:46:49 UTC+2:
    Hello,
    I am starting FORTH for a small non commercial project and perhaps somebody here could support a bit?

    For multiplication by 2 of a variable R, I made

    R F@
    2.0e
    F*
    R F!

    Is there any method to not make moving the stack?

    Word "F2*" would multiplicate the value of R by 2 direct in address..
    "R F2*"

    Or Word "FX*" would multiplicate the value of R by X direct in address.. (in this case the stack would move only by 1 level which would be ok for me)
    "1.234e FX* R"

    Any advice / hint how to design the words F2* or FX* is welcome.


    Why is it necessary to not move the stack?

    If eliminating stack juggling was good, it follows eliminating the stack
    is better. Locals users should understand this better than anyone.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From pascal dagornet@21:1/5 to dxforth on Tue May 23 23:30:31 2023
    dxforth schrieb am Mittwoch, 24. Mai 2023 um 03:08:14 UTC+2:
    On 24/05/2023 7:26 am, minforth wrote:
    pascal dagornet schrieb am Dienstag, 23. Mai 2023 um 09:46:49 UTC+2:
    Hello,
    I am starting FORTH for a small non commercial project and perhaps somebody here could support a bit?

    For multiplication by 2 of a variable R, I made

    R F@
    2.0e
    F*
    R F!

    Is there any method to not make moving the stack?

    Word "F2*" would multiplicate the value of R by 2 direct in address..
    "R F2*"

    Or Word "FX*" would multiplicate the value of R by X direct in address.. (in this case the stack would move only by 1 level which would be ok for me)
    "1.234e FX* R"

    Any advice / hint how to design the words F2* or FX* is welcome.


    Why is it necessary to not move the stack?
    If eliminating stack juggling was good, it follows eliminating the stack
    is better. Locals users should understand this better than anyone.

    "Why is it necessary to not move the stack?"

    I am making (what I call) an adapter:
    - for programming FORTH for HP71B ( https://en.wikipedia.org/wiki/HP-71B ) under a gforth environment in emacs on a PC
    - since the FORTH for the HP71B has a fixed stack of 4, then programming on the PC should reflects this (I know, thats weird)

    Why using a PC for programming an HP71B?
    a) writing/debugging FORTH in HP71B directly is terrible (1 line display)
    b) writing programs under emacs and gforth on a PC is a good feeling
    .. when the programms are working in gforth/emacs, then a quick check will be done in the HP71B emulator in the PC then the program can be transferred to a real HP71B via HP-IL interface (PC interface supported via a pillbox)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to pascal dagornet on Wed May 24 07:51:45 2023
    pascal dagornet <pascaldagornet@gmail.com> writes:
    - for programming FORTH for HP71B ( https://en.wikipedia.org/wiki/HP-71B ) under a gforth environment in emacs on a PC
    - since the FORTH for the HP71B has a fixed stack of 4, then programming on the PC should reflects this (I know, thats weird)

    Even Chuck Moore, who is more minimalist than most, never went below 6
    stack items in his hardware, and he uses the registers A and R in
    addition, which probably help reduce the needed stack depth.

    <https://en.wikipedia.org/wiki/RPL_(programming_language)> says:
    |Contrary to previous HP RPN calculators, which had a fixed four-level
    |stack, the stack used by RPL is only limited by available calculator
    |RAM.

    Googling for "RPL HP-71B" gives some hits (which I have not really
    dived into), including a youtube video titled "HP 71B -
    FORTH/Assembler ROM from 1984 - YouTube" <https://www.youtube.com/watch?v=0gjdUPmwBbs>.

    - anton
    --
    M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
    comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
    New standard: https://forth-standard.org/
    EuroForth 2022: https://euro.theforth.net

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From pascal dagornet@21:1/5 to minforth on Wed May 24 02:56:32 2023
    minforth schrieb am Dienstag, 23. Mai 2023 um 23:26:43 UTC+2:
    pascal dagornet schrieb am Dienstag, 23. Mai 2023 um 09:46:49 UTC+2:
    Hello,
    I am starting FORTH for a small non commercial project and perhaps somebody here could support a bit?

    For multiplication by 2 of a variable R, I made

    R F@
    2.0e
    F*
    R F!

    Is there any method to not make moving the stack?

    Word "F2*" would multiplicate the value of R by 2 direct in address..
    "R F2*"

    Or Word "FX*" would multiplicate the value of R by X direct in address.. (in this case the stack would move only by 1 level which would be ok for me)
    "1.234e FX* R"

    Any advice / hint how to design the words F2* or FX* is welcome.

    Why is it necessary to not move the stack?

    Somewhat simpler: make F an FVALUE instead of an FVARIABLE, then do
    F +TO F
    My setup is:
    a) working in GFORTH (+TO is there; I could not see FVALUE)
    b) Move the code to another FORTH (FVALUE and +TO not there)
    So, I should know how to make FVALUE and "TO from scratch.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)