Post Reply 
FORTH & HP: where to start?
04-15-2023, 08:14 PM
Post: #1
FORTH & HP: where to start?
Hello,
I was discussing with a family member and asked for a FORTH calculator based on Arduino since I have interest (on my 100+ project list).
But it could become a longer project.
So, has anybody any recommendation where to start with FORTH from scratch? (I will not wait for the project but could use an existing calculator).
a) what are the FORTH similar HP calculator?
b) is an HP50 with FORTH a good start? (I could see an announcement it has a FORTH module which can be implemented). I have no HP50: I should invest.
b) the HP71B with FORTH would be a quick easy solution? (I have an HP71B and never tried FORTH)
any recommendation where/how to start is more than welcome = advice what calculator would be the best for
- editing,
- storing programs on USB/virtual drive,
- what debugging method should be used
.. finally similar advices like here for HP41 debugging https://www.hpmuseum.org/forum/thread-19806.html

HP71B 4TH/ASM/Multimod, HP41CV/X/Y & Nov64d, PILBOX, HP-IL 821.62A & 64A & 66A, Deb11 64b-PC & PI2 3 4 w/ ILPER, VIDEO80, V41 & EMU71, DM41X
Find all posts by this user
Quote this message in a reply
04-15-2023, 08:57 PM
Post: #2
RE: FORTH & HP: where to start?
(04-15-2023 08:14 PM)floppy Wrote:  b) the HP71B with FORTH would be a quick easy solution? (I have an HP71B and never tried FORTH)

I have the 82441A Forth/Assembler module, and I started with that and Leo Brodie's book "Starting Forth"  which is very dated but still very good.  Actually, Forth, Inc. has it online now with the original cartoons but some material updates for ANS Forth at http://www.forth.com/starting-forth/.  It was a little bit difficult to get started, because the book assumed you had something to practice on, and the HP-71 module's manual assumed you were already familiar with Forth and only needed to know its peculiarities like about the 20-bit cells and nybble-wide content of any given single address.  I did eventually get going though, and enjoyed it.  I think it's mostly a Forth-79, not Forth-83, and it was out a decade before ANS Forth.  My later Forth work, much more voluminous and in-depth, was on another processor, on a workbench computer of my own making.

The Forth in this module is a rather poor implementation of Forth.  I can't believe how slow many of the Forth words are.  But, being Forth, it allows you to replace words with your own definitions and speed them up.  Re-writing many of them in Forth as secondaries, ie, without even using assembly and writing primitives, I was able to improve their speed by a factor of anywhere from two to fourteen! (CHR$ was the one I made 14x as fast.)  Someone here asked me to round up my materials on it and post them; unfortunately I find they're in quite a disarray and I've hardly worked with it in decades, so it turned out to be too big a project.

http://WilsonMinesCo.com  (Lots of HP-41 links at the bottom of the links page, at http://wilsonminesco.com/links.html#hp41 )
Visit this user's website Find all posts by this user
Quote this message in a reply
04-15-2023, 09:13 PM
Post: #3
RE: FORTH & HP: where to start?
Start with the 71B implementation of FORTH and work your way through the manual to understand its capabilities. The 71B FORTH is not so much a separate programming language, as it is more like an integrated extension of the built-in BASIC. The ROM includes a decent editor in the style of EDT/ed when writing your own programs. I personally prefer a printed, spiral-bound, lay-flat manual for ease of reading and later reference. If you want to develop in a desktop environment before transferring to the 71, look for gforth and its extensive manual. There will of course be many differences in the two vocabularies but you can write your own versions of ANS words for practice!

Remember kids, "In a democracy, you get the government you deserve."
Find all posts by this user
Quote this message in a reply
04-15-2023, 11:16 PM
Post: #4
RE: FORTH & HP: where to start?
There are Arduino/microcontroller Forth like flashForth you could start with.
Find all posts by this user
Quote this message in a reply
04-16-2023, 03:01 PM (This post was last modified: 04-16-2023 03:08 PM by floppy.)
Post: #5
RE: FORTH & HP: where to start?
(04-15-2023 11:16 PM)EugeneNine Wrote:  There are Arduino/microcontroller Forth like flashForth you could start with.
+1.
Do you know anything package ready to use with screen and keyboard?
keyboard? https://www.hackster.io/cameroncoward/64...ino-4c9531
Screen? https://funduino.de/anleitung-4x20-i%C2%B2c-lcd-modul
https://www.az-delivery.de/en/blogs/azde...ft-display
Suggestions are welcome.
.. then I will throw the whole package to the family member and wish a completion for christmas ;-)

In parallel I am starting to setup V71 for FORTH.

HP71B 4TH/ASM/Multimod, HP41CV/X/Y & Nov64d, PILBOX, HP-IL 821.62A & 64A & 66A, Deb11 64b-PC & PI2 3 4 w/ ILPER, VIDEO80, V41 & EMU71, DM41X
Find all posts by this user
Quote this message in a reply
04-16-2023, 08:47 PM
Post: #6
RE: FORTH & HP: where to start?
Check the list of possible hosts here

https://mecrisp.sourceforge.net/

Not quite package-ready, but a serial console starting point to add support for keyboard & display.

Remember kids, "In a democracy, you get the government you deserve."
Find all posts by this user
Quote this message in a reply
04-16-2023, 09:14 PM (This post was last modified: 04-16-2023 09:15 PM by BobVA.)
Post: #7
RE: FORTH & HP: where to start?
And there's this:

SCAMP embedded Forth microcontroller board

(...been on my radar but I haven't ordered one yet.)
Find all posts by this user
Quote this message in a reply
04-16-2023, 11:02 PM
Post: #8
RE: FORTH & HP: where to start?
I you want a calculator, and accept non-HP calculators, you can try Forth500 for the SHARP PC-E500 (S), and Forth850 for the SHARP PC-G850 (V) (S) (VS).
They are based on the most recent standard of the language.

Forth500, that I know the best, is very complete. It can use two editors, TED and the built-in BASIC editor via TLOAD, and programs can be stored on a computer via a serial link, or with a cassette interface.

Jean-Charles
Find all posts by this user
Quote this message in a reply
05-07-2023, 10:45 AM
Post: #9
RE: FORTH & HP: where to start?
(04-15-2023 09:13 PM)mfleming Wrote:  gforth and its extensive manual
+1
What environment should I use for debugging? (IDE)
I have some experience with few IDEs
- jupyter for python (after few works on spyder and pycharm)
- eclipse for PROLOG
- geany for PROLOG (since there was a plugin for syntax edition)
anything from them would be welcome (using a new tool is a new headache)

I am reading "Starting forth" and should next jump into coding.

What would be the best method to include such example of programs into the HP71B? (see below).
My impression..
- gforth & IDE use on a PC (a bit like "CC41" but now for Forth and as near to HP71B forth as possible)
- developping new words for previous programm for making it running in HP71B
- storing a file "prog1.txt" into the PC (64bits linux)
- using a pre-processing (like HP41UC) for compiling the tested file TXT above; method still not found except putting manually all lines into the HP71B. Any hint is welcome.
- if a file PROG1.DAT is created from the previous pre-processor, then upload in EMU71 w/ forth module for further testing
- when tested in EMU71, then store the file into a virtual drive
- retrieve the program file from the virtual drive into an HP71B hardware (pilbox and hpil in place)
-.. use it

Thanks for showing me any programming / debugging / transfering forth programs from a PC workstation into an HP71B (with pilbox and HP-IL)

https://www.forth.com/starting-forth/12-...e-example/
Code:
\ "No Weighting" from Starting Forth Chapter 12
VARIABLE DENSITY
VARIABLE THETA
VARIABLE ID

: " ( -- addr )   [CHAR] " WORD DUP C@ 1+ ALLOT ;

: MATERIAL ( addr n1 n2 -- )    \ addr=string, n1=density, n2=theta
   CREATE  , , , 
   DOES> ( -- )   DUP @ THETA !
   CELL+ DUP @ DENSITY !  CELL+ @ ID ! ;

: .SUBSTANCE ( -- )   ID @ COUNT TYPE ;
: FOOT ( n1 -- n2 )   10 * ;
: INCH ( n1 -- n2 )   100 12 */  5 +  10 /  + ;
: /TAN ( n1 -- n2 )   1000 THETA @ */ ;

: PILE ( n -- )         \ n=scaled height
   DUP DUP 10 */ 1000 */  355 339 */  /TAN /TAN
   DENSITY @ 200 */  ." = " . ." tons of "  .SUBSTANCE ;

\ table of materials
\   string-address  density  tan[theta] 
   " cement"           131        700  MATERIAL CEMENT
   " loose gravel"      93        649  MATERIAL LOOSE-GRAVEL
   " packed gravel"    100        700  MATERIAL PACKED-GRAVEL
   " dry sand"          90        754  MATERIAL DRY-SAND
   " wet sand"         118        900  MATERIAL WET-SAND
   " clay"             120        727  MATERIAL CLAY

HP71B 4TH/ASM/Multimod, HP41CV/X/Y & Nov64d, PILBOX, HP-IL 821.62A & 64A & 66A, Deb11 64b-PC & PI2 3 4 w/ ILPER, VIDEO80, V41 & EMU71, DM41X
Find all posts by this user
Quote this message in a reply
05-07-2023, 10:46 AM (This post was last modified: 05-07-2023 10:48 AM by floppy.)
Post: #10
RE: FORTH & HP: where to start?
(04-16-2023 11:02 PM)Helix Wrote:  I you want a calculator, and accept non-HP calculators, you can try Forth500 for the SHARP PC-E500 (S), and Forth850 for the SHARP PC-G850 (V) (S) (VS).
They are based on the most recent standard of the language.

Forth500, that I know the best, is very complete. It can use two editors, TED and the built-in BASIC editor via TLOAD, and programs can be stored on a computer via a serial link, or with a cassette interface.
Thanks for the advice. I decided (for now) to stubbornly stick with the HP71B.

HP71B 4TH/ASM/Multimod, HP41CV/X/Y & Nov64d, PILBOX, HP-IL 821.62A & 64A & 66A, Deb11 64b-PC & PI2 3 4 w/ ILPER, VIDEO80, V41 & EMU71, DM41X
Find all posts by this user
Quote this message in a reply
05-08-2023, 11:04 AM
Post: #11
RE: FORTH & HP: where to start?
(05-07-2023 10:45 AM)floppy Wrote:  
(04-15-2023 09:13 PM)mfleming Wrote:  gforth and its extensive manual
+1
What environment should I use for debugging? (IDE)
I have some experience with few IDEs

I've never bothered with an IDE, I simply break a program up into a set of files with related words and debug each word set. A master file includes the working files in the right order. Save and reload a working dictionary as you go along is another good approach.

If you're interested in documenting your work as you develop, you could try a Jupyter notebook- kernel here. Haven't tried it myself so I can't comment on its effectiveness.

https://github.com/jdfreder/iforth

Remember kids, "In a democracy, you get the government you deserve."
Find all posts by this user
Quote this message in a reply
05-08-2023, 02:30 PM
Post: #12
RE: FORTH & HP: where to start?
(05-08-2023 11:04 AM)mfleming Wrote:  1. Save and reload a working dictionary as you go along is another good approach.

2. https://github.com/jdfreder/iforth

To 1. How to do this with an HP71B?

To 2. I tried and failed so far
pip install https://github.com/jdfreder/iforth
Code:
Collecting https://github.com/jdfreder/iforth
  Downloading https://github.com/jdfreder/iforth
     / 195.0 kB 1.8 MB/s 0:00:00
  ERROR: Cannot unpack file /tmp/pip-unpack-_45eynfv/iforth (downloaded from /tmp/pip-req-build-ixzfbmei, content-type: text/html; charset=utf-8); cannot detect archive format
ERROR: Cannot determine archive format of /tmp/pip-req-build-ixzfbmei
pip is there..
Code:
pip install -U pip
Requirement already satisfied: pip in ./anaconda3/lib/python3.8/site-packages (22.2.2)
Collecting pip
  Downloading pip-23.1.2-py3-none-any.whl (2.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 1.5 MB/s eta 0:00:00
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 22.2.2
    Uninstalling pip-22.2.2:
      Successfully uninstalled pip-22.2.2
Successfully installed pip-23.1.2

HP71B 4TH/ASM/Multimod, HP41CV/X/Y & Nov64d, PILBOX, HP-IL 821.62A & 64A & 66A, Deb11 64b-PC & PI2 3 4 w/ ILPER, VIDEO80, V41 & EMU71, DM41X
Find all posts by this user
Quote this message in a reply
05-08-2023, 06:04 PM
Post: #13
RE: FORTH & HP: where to start?
1. Transfer finished files to the 71B using a PIL-Box.

2. Never tried this. The repo is six years old, so probably not even supported by the author anymore.

Do a search on "Forth IDE" and you'll find links to SwiftForth by Forth Inc, or VFX Forth for Windows by MPE (MicroProcessor Engineering Ltd). Both are freely downloadable but may time out and request a license.

Note that emacs has a Forth mode for files with the '.fs' extension. Has keyword coloring support but little else. Hit F10 to access menu bar. The command M-x shell will spawn a shell you can interact with to run gforth and feed it commands.

Old (ahem, 'seasoned') programmers like me would consider emacs a perfectly good IDE.

Remember kids, "In a democracy, you get the government you deserve."
Find all posts by this user
Quote this message in a reply
05-09-2023, 10:16 AM
Post: #14
RE: FORTH & HP: where to start?
(05-08-2023 06:04 PM)mfleming Wrote:  1. Transfer finished files to the 71B using a PIL-Box.

2. Never tried this. The repo is six years old, so probably not even supported by the author anymore.

Do a search on "Forth IDE" and you'll find links to SwiftForth by Forth Inc, or VFX Forth for Windows by MPE (MicroProcessor Engineering Ltd). Both are freely downloadable but may time out and request a license.

Note that emacs has a Forth mode for files with the '.fs' extension. Has keyword coloring support but little else. Hit F10 to access menu bar. The command M-x shell will spawn a shell you can interact with to run gforth and feed it commands.

Old (ahem, 'seasoned') programmers like me would consider emacs a perfectly good IDE.
1. HowTo?
EMU71 & Forth, ILPER, Virtual drive on PC
HP71B w/ FORTH with pilbox (ilpilbox, ilper..) connection to that PC (one time I just uploaded so far JF Garnier "reversi" into the HP71B)

This file tt.fth

Code:
\
\ tt.pfe    Tetris for terminals, redone in ANSI-Forth.
\        Written 05Apr94 by Dirk Uwe Zoller,
\            e-mail duz@roxi.rz.fht-mannheim.de.
\        Look&feel stolen from Mike Taylor's "TETRIS FOR TERMINALS"
\
\        Please copy and share this program, modify it for your system
\        and improve it as you like. But don't remove this notice.
\
\        Thank you.
\


only forth also definitions
s" forget-tt" drop 1- find nip [if] forget-tt [then] marker forget-tt

vocabulary tetris  tetris also definitions

decimal

\ Variables, constants

bl bl 2constant empty        \ an empty position
variable wiping            \ if true: wipe brick, else draw brick
 2 constant col0        \ position of the pit
 0 constant row0

10 constant wide        \ size of pit in brick positions
20 constant deep

char J    value left-key        \ customize if you don't like them
char K    value rot-key
char L    value right-key
bl    value drop-key
char P    value pause-key
12    value refresh-key
char Q    value quit-key

variable score
variable pieces
variable levels
variable delay

variable brow            \ where the brick is
variable bcol


\ stupid random number generator

variable seed

: randomize    time&date + + + + + seed ! ;

: random    \ max --- n ; return random number < max
        seed @ 13 * [ hex ] 07FFF [ decimal ] and
        dup seed !  swap mod ;


\ Access pairs of characters in memory:

: 2c@        dup 1+ c@ swap c@ ;
: 2c!        dup >r c! r> 1+ c! ;

\ : d<>        d= not ;  \ kForth
  : d<>        d= 0=  ;  \ gForth: use 0= instead of NOT. 



\ Drawing primitives:

: 2emit        emit emit ;

: position    \ row col --- ; cursor to the position in the pit
        2* col0 + swap row0 + at-xy ;

: stone        \ c1 c2 --- ; draw or undraw these two characters
        wiping @ if  2drop 2 spaces  else  2emit  then ;


\ Define the pit where bricks fall into:

: def-pit    create    wide deep * 2* allot
        does>    rot wide * rot + 2* + ;

def-pit pit

: empty-pit    deep 0 do wide 0 do  empty j i pit 2c!
        loop loop ;


\ Displaying:

: draw-bottom    \ --- ; redraw the bottom of the pit
        deep -1 position
        [char] + dup stone
        wide 0 do  [char] = dup stone  loop
        [char] + dup stone ;

: draw-frame    \ --- ; draw the border of the pit
        deep 0 do
            i -1   position [char] | dup stone
            i wide position [char] | dup stone
        loop  draw-bottom ;

: bottom-msg    \ addr cnt --- ; output a message in the bottom of the pit
        deep over 2/ wide swap - 2/ position type ;

: draw-line    \ line ---
        dup 0 position  wide 0 do  dup i pit 2c@ 2emit  loop  drop ;

: draw-pit    \ --- ; draw the contents of the pit
        deep 0 do  i draw-line  loop ;

: show-key    \ char --- ; visualization of that character
        dup bl <
        if  [char] @ or  [char] ^ emit  emit  space
        else  [char] ` emit  emit  [char] ' emit
        then ;

: show-help    \ --- ; display some explanations
        30  1 at-xy ." ***** T E T R I S *****"
        30  2 at-xy ." ======================="
        30  4 at-xy ." Use keys:"
        32  5 at-xy left-key    show-key ."  Move left"
        32  6 at-xy rot-key    show-key ."  Rotate"
        32  7 at-xy right-key    show-key ."  Move right"
        32  8 at-xy drop-key    show-key ."  Drop"
        32  9 at-xy pause-key    show-key ."  Pause"
        32 10 at-xy refresh-key    show-key ."  Refresh"
        32 11 at-xy quit-key    show-key ."  Quit"
        32 13 at-xy ." -> "
        30 16 at-xy ." Score:"
        30 17 at-xy ." Pieces:"
        30 18 at-xy ." Levels:"
         0 22 at-xy ."  ==== This program was written 1994 in pure dpANS Forth by Dirk Uwe Zoller ===="
         0 23 at-xy ."  =================== Copy it, port it, play it, enjoy it! =====================" ;

: update-score    \ --- ; display current score
        38 16 at-xy score @ 3 .r
        38 17 at-xy pieces @ 3 .r
        38 18 at-xy levels @ 3 .r ;

: refresh    \ --- ; redraw everything on screen
        page draw-frame draw-pit show-help update-score ;


\ Define shapes of bricks:

: def-brick    create    4 0 do
                ' execute  0 do  dup i chars + c@ c,  loop drop
                refill drop
            loop
        does>    rot 4 * rot + 2* + ;

def-brick brick1    s"         "
            s" ######  "
            s"   ##    "
            s"         "

def-brick brick2    s"         "
            s" <><><><>"
            s"         "
            s"         "

def-brick brick3    s"         "
            s"   {}{}{}"
            s"   {}    "
            s"         "

def-brick brick4    s"         "
            s" ()()()  "
            s"     ()  "
            s"         "

def-brick brick5    s"         "
            s"   [][]  "
            s"   [][]  "
            s"         "

def-brick brick6    s"         "
            s" @@@@    "
            s"   @@@@  "
            s"         "

def-brick brick7    s"         "
            s"   %%%%  "
            s" %%%%    "
            s"         "

\ this brick is actually in use:

def-brick brick        s"         "
            s"         "
            s"         "
            s"         "

def-brick scratch    s"         "
            s"         "
            s"         "
            s"         "

create bricks    ' brick1 ,  ' brick2 ,  ' brick3 ,  ' brick4 ,
        ' brick5 ,  ' brick6 ,  ' brick7 ,

create brick-val 1 c, 2 c, 3 c, 3 c, 4 c, 5 c, 5 c,


: is-brick    \ brick --- ; activate a shape of brick
        >body ['] brick >body 32 cmove ;

: new-brick    \ --- ; select a new brick by random, count it
        1 pieces +!  7 random
        bricks over cells + @ is-brick
        brick-val swap chars + c@ score +! ;

: rotleft    4 0 do 4 0 do
            j i brick 2c@  3 i - j scratch 2c!
        loop loop
        ['] scratch is-brick ;

: rotright    4 0 do 4 0 do
            j i brick 2c@  i 3 j - scratch 2c!
        loop loop
        ['] scratch is-brick ;

: draw-brick    \ row col ---
        4 0 do 4 0 do
            j i brick 2c@  empty d<>
            if  over j + over i +  position
            j i brick 2c@  stone
            then
        loop loop  2drop ;

: show-brick    wiping off draw-brick ;
: hide-brick    wiping on  draw-brick ;

: put-brick    \ row col --- ; put the brick into the pit
        4 0 do 4 0 do
            j i brick 2c@  empty d<>
            if  over j +  over i +  pit
            j i brick 2c@  rot 2c!
            then
        loop loop  2drop ;

: remove-brick    \ row col --- ; remove the brick from that position
        4 0 do 4 0 do
            j i brick 2c@  empty d<>
            if  over j + over i + pit empty rot 2c!  then
        loop loop  2drop ;

: test-brick    \ row col --- flag ; could the brick be there?
        4 0 do 4 0 do
            j i brick 2c@ empty d<>
            if  over j +  over i +
            over dup 0< swap deep >= or
            over dup 0< swap wide >= or
            2swap pit 2c@  empty d<>
            or or if  unloop unloop 2drop false  exit  then
            then
        loop loop  2drop true ;

: move-brick    \ rows cols --- flag ; try to move the brick
        brow @ bcol @ remove-brick
        swap brow @ + swap bcol @ + 2dup test-brick
        if  brow @ bcol @ hide-brick
            2dup bcol ! brow !  2dup show-brick put-brick  true
        else  2drop brow @ bcol @ put-brick  false
        then ;

: rotate-brick    \ flag --- flag ; left/right, success
        brow @ bcol @ remove-brick
        dup if  rotright  else  rotleft  then
        brow @ bcol @ test-brick
        over if  rotleft  else  rotright  then
        if  brow @ bcol @ hide-brick
            if  rotright  else  rotleft  then
            brow @ bcol @ put-brick
            brow @ bcol @ show-brick  true
        else  drop false  then ;

: insert-brick    \ row col --- flag ; introduce a new brick
        2dup test-brick
        if  2dup bcol ! brow !
            2dup put-brick  draw-brick  true
        else  false  then ;

: drop-brick    \ --- ; move brick down fast
        begin  1 0 move-brick 0=  until ;

: move-line    \ from to ---
        over 0 pit  over 0 pit  wide 2*  cmove  draw-line
        dup 0 pit  wide 2*  blank  draw-line ;

: line-full    \ line-no --- flag
        true  wide 0
        do  over i pit 2c@ empty d=
            if  drop false  leave  then
        loop nip ;

: remove-lines    \ ---
        deep deep
        begin
            swap
            begin  1- dup 0< if  2drop exit  then  dup line-full
            while  1 levels +!  10 score +!  repeat
            swap 1-
            2dup <> if  2dup move-line  then
        again ;

: to-upper    \ char --- char ; convert to upper case
        dup [char] a >= over [char] z <= and if  bl -  then ;

: interaction    \ --- flag
        case  key to-upper
            left-key    of  0 -1 move-brick drop  endof
            right-key    of  0  1 move-brick drop  endof
            rot-key    of  0 rotate-brick drop  endof
            drop-key    of  drop-brick  endof
            pause-key    of  S"  paused " bottom-msg  key drop
                    draw-bottom  endof
            refresh-key    of  refresh  endof
            quit-key    of  false exit  endof
        endcase  true ;

: initialize    \ --- ; prepare for playing
        randomize empty-pit refresh
        0 score !  0 pieces !  0 levels !  100 delay ! ;

: adjust-delay    \ --- ; make it faster with increasing score
        levels @
        dup  50 < if  100 over -  else
        dup 100 < if   62 over 4 / -  else
        dup 500 < if   31 over 16 / -  else  0  then then then
        delay !  drop ;

: play-game    \ --- ; play one tetris game
        begin
            new-brick
            -1 3 insert-brick
        while
            begin  4 0
            do  35 13 at-xy
                delay @ ms key?
                if  interaction 0=
                if  unloop exit  then
                then
            loop
            1 0 move-brick  0=
            until
            remove-lines
            update-score
            adjust-delay
        repeat ;

forth definitions

: tt        \ --- ; play the tetris game
        initialize
        s"  Press any key " bottom-msg key drop draw-bottom
        begin
            play-game
            s"  Again? " bottom-msg key to-upper [char] Y =
        while  initialize  repeat
        0 23 at-xy cr ;

only forth also definitions


2. emacs looks good. I keep it.

HP71B 4TH/ASM/Multimod, HP41CV/X/Y & Nov64d, PILBOX, HP-IL 821.62A & 64A & 66A, Deb11 64b-PC & PI2 3 4 w/ ILPER, VIDEO80, V41 & EMU71, DM41X
Find all posts by this user
Quote this message in a reply
05-16-2023, 07:31 PM
Post: #15
RE: FORTH & HP: where to start?
Has anybody few FORTH programs, in text form in the internet, which were running/tested on HP71B ?

in the forum here I find a pi program https://www.hpmuseum.org/cgi-sys/cgiwrap...ead=148399 and I need more with especially STO and RCL (not from the translator).

However, so far I understood, if any forth program in a lif file is announced, I should be able to extract it with lifutils (I never has done it; I suppose it should be easy). So, whatever, any announced program (and where to find it) is welcome.

Why I am searching few programs?: in the similar idea of 41CC https://github.com/CraigBladow/cc41 I am writing a forth debugger for HP71B on a PC and need few test programs (which has a confirmed work; else I must debug the debugger on the pc and debug remotely the programs on a PC which could only be tested on an hp71b hardware by transfering them there)

My action plan is
a) develop a pre-processor (debugger) on PC for HP71B forth (exists; testing on-going)
b) receive or develop bug free programs on an HP71B hardware (I will get them from here?)
c) put that programs on a PC in order to use them as testing reference program for a new debugger

HP71B 4TH/ASM/Multimod, HP41CV/X/Y & Nov64d, PILBOX, HP-IL 821.62A & 64A & 66A, Deb11 64b-PC & PI2 3 4 w/ ILPER, VIDEO80, V41 & EMU71, DM41X
Find all posts by this user
Quote this message in a reply
05-16-2023, 09:55 PM
Post: #16
RE: FORTH & HP: where to start?
Here's a 71B RAM Editor.

The original was published in a PPC Journal article back in the day (I can find a reference if needed). In the original article, a BASIC call was used for the INADDR function, but that seemed morally wrong, so I rewrote it using FORTH (though fairly ugly, inelegant and likely not efficient, but it works, and hey, it was some of the very first FORTH I ever wrote...).

Code:
BASE @ HEX
: INADDR  ( str -- n )
( Prompts for and returns a number )
( Start number with "T" for decimal, )
( else HEX is assumed )
  TYPE BASE @ HEX
  PAD 2+ DUP DUP EXPECT96 CR
  SPAN @ SWAP 2- C!
  DUP C@ 54 =
  IF
    DECIMAL DUP DUP 2-
    C@ 1- SWAP C!
  ELSE
    2-
  THEN
  NUMBER DROP SWAP
  BASE ! ;

16 STRING PR$ " FFFFF: F F F (F) F F F" PR$ S!
: NORL 30 + DUP 39 > IF 7 + THEN ;
: SADDR SP@ DUP 5+ SWAP DO I N@ NORL LOOP PR$ DROP DUP
  A + SWAP DO I C! 2 +LOOP ;
: ST + DUP ROT ROT C! ;
: LPR$ DUP DUP 3 - SWAP 3 + DO I N@ NORL -1 +LOOP PR$
  DROP E ST 4 ST 4 ST 6 ST 6 ST 4 ST 4 ST DROP ;
: R? KEY D = IF OVER N! 1+ ELSE DROP THEN ;
: KEY? CASE
  8 OF 1- ENDOF
  9 OF 1+ ENDOF
  7 OF 2- ENDOF
  0 OF 2+ ENDOF
  5 OF 5- ENDOF
  6 OF 5+ ENDOF
  47 OF CR DROP " Addr: " INADDR ENDOF
  52 OF CR " Addr: " INADDR + ENDOF
  30 OF 0 R? ENDOF
  31 OF 1 R? ENDOF
  32 OF 2 R? ENDOF
  33 OF 3 R? ENDOF
  34 OF 4 R? ENDOF
  35 OF 5 R? ENDOF
  36 OF 6 R? ENDOF
  37 OF 7 R? ENDOF
  38 OF 8 R? ENDOF
  39 OF 9 R? ENDOF
  41 OF A R? ENDOF
  42 OF B R? ENDOF
  43 OF C R? ENDOF
  44 OF D R? ENDOF
  45 OF E R? ENDOF
  46 OF F R? ENDOF
  ENDCASE ;
: RAMED BEGIN CR LPR$ SADDR PR$ TYPE KEY KEY? 0 UNTIL ;
BASE !

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
05-17-2023, 12:40 AM
Post: #17
RE: FORTH & HP: where to start?
Check out NQueens in FORTH for the 71b here.

(05-16-2023 07:31 PM)floppy Wrote:  Has anybody few FORTH programs, in text form in the internet, which were running/tested on HP71B ?

Calculator Clique on YouTube
Visit this user's website Find all posts by this user
Quote this message in a reply
05-17-2023, 09:13 AM
Post: #18
RE: FORTH & HP: where to start?
(05-17-2023 12:40 AM)dmh Wrote:  Check out NQueens in FORTH for the 71b here.

(05-16-2023 07:31 PM)floppy Wrote:  Has anybody few FORTH programs, in text form in the internet, which were running/tested on HP71B ?

wonderfull. a good thing in order to see if my debugger works.
What does mean "HP-41 Translator ROM Module HP-82490A" ? I dont understand since I dont see any RPN code in it.

Code:
 HP-71B / Forth / HP-41 Translator ROM Module HP-82490A
--------------------------------------------------------


 : NQUEENSF ;
 FVARIABLE TIMER
 : STARTTIMER CLOCK TIMER STO ;
 : DISPLAYTIMER CLOCK TIMER RCL F- STD F. ." SEC" ;
 8 CONSTANT RR
 VARIABLE SS
 VARIABLE XX
 VARIABLE YY
 CREATE AA RR 1 + ALLOT
 : RCLAA @ 2 * AA + C@ ;
 : STOAA @ 2 * AA + C! ;
 : NQCORE
   0 SS !
   0 XX !
   BEGIN
     1 XX +! RR XX STOAA
     BEGIN
       1 SS +!
       XX @ YY !
       BEGIN YY @ 1 > WHILE
         -1 YY +!
         XX RCLAA YY RCLAA - DUP
         0 = SWAP ABS XX @ YY @ - = OR IF
           0 YY !
           BEGIN XX RCLAA 1 - DUP XX STOAA 0 = WHILE
             -1 XX +!
           REPEAT
         THEN
       REPEAT
     YY @ 1 = UNTIL
   RR XX @ = UNTIL
 ;
 : NQUEENS
   STARTTIMER
   NQCORE
   ." S=" SS @ . ." IN "
   DISPLAYTIMER CR
 ;

HP71B 4TH/ASM/Multimod, HP41CV/X/Y & Nov64d, PILBOX, HP-IL 821.62A & 64A & 66A, Deb11 64b-PC & PI2 3 4 w/ ILPER, VIDEO80, V41 & EMU71, DM41X
Find all posts by this user
Quote this message in a reply
05-17-2023, 11:22 AM (This post was last modified: 05-17-2023 11:30 AM by ThomasF.)
Post: #19
RE: FORTH & HP: where to start?
(05-17-2023 09:13 AM)floppy Wrote:  What does mean "HP-41 Translator ROM Module HP-82490A" ? I dont understand since I dont see any RPN code in it.

Hi,

Don't have the module anymore, but it does also contain Forth.
I.e. you could either use the Forth/Assembler module or the Forth/Translator module for Forth programming.
AFAIK the two Forth implementations are basically identical apart from the assembler part in the first module and built-in words for RPN/HP41 in the other.

So my guess is that the reference indicates that you could use either of the modules to run the program.

EDIT: Sorry, but no, that was not fully correct. I noticed that the word "CLOCK" is used, and that is only available in the Translator module!
So the stopwatch functions must be rewritten if the Assembler module is used ...


Cheers,
Thomas

[35/45/55/65/67/97/80 21/25/29C 31E/32E/33E|C/34C/38E 41C|CV|CX 71B 10C/11C/12C/15C|CE/16C 32S|SII/42S 28C|S 48GX/49G/50G 35S 41X]
Find all posts by this user
Quote this message in a reply
05-17-2023, 11:37 AM
Post: #20
RE: FORTH & HP: where to start?
(05-17-2023 11:10 AM)floppy Wrote:  Can you submit this EXPECT96 word?

EXPECT96 is a built-in word in the Forth-module (both Assembler and Translator module).

   

Cheers,
Thomas

[35/45/55/65/67/97/80 21/25/29C 31E/32E/33E|C/34C/38E 41C|CV|CX 71B 10C/11C/12C/15C|CE/16C 32S|SII/42S 28C|S 48GX/49G/50G 35S 41X]
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 8 Guest(s)