Post Reply 
FORTH & HP: where to start?
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
Post Reply 


Messages In This Thread
FORTH & HP: where to start? - floppy - 04-15-2023, 08:14 PM
RE: FORTH & HP: where to start? - mfleming - 04-15-2023, 09:13 PM
RE: FORTH & HP: where to start? - floppy - 05-07-2023, 10:45 AM
RE: FORTH & HP: where to start? - mfleming - 05-08-2023, 11:04 AM
RE: FORTH & HP: where to start? - floppy - 05-08-2023, 02:30 PM
RE: FORTH & HP: where to start? - floppy - 04-16-2023, 03:01 PM
RE: FORTH & HP: where to start? - mfleming - 04-16-2023, 08:47 PM
RE: FORTH & HP: where to start? - BobVA - 04-16-2023, 09:14 PM
RE: FORTH & HP: where to start? - Helix - 04-16-2023, 11:02 PM
RE: FORTH & HP: where to start? - floppy - 05-07-2023, 10:46 AM
RE: FORTH & HP: where to start? - mfleming - 05-08-2023, 06:04 PM
RE: FORTH & HP: where to start? - floppy - 05-09-2023, 10:16 AM
RE: FORTH & HP: where to start? - floppy - 05-16-2023, 07:31 PM
RE: FORTH & HP: where to start? - dmh - 05-17-2023, 12:40 AM
RE: FORTH & HP: where to start? - floppy - 05-17-2023, 09:13 AM
RE: FORTH & HP: where to start? - ThomasF - 05-17-2023, 11:22 AM
RE: FORTH & HP: where to start? - ThomasF - 05-18-2023, 08:04 AM
RE: FORTH & HP: where to start? - floppy - 05-28-2023, 08:38 PM
RE: FORTH & HP: where to start? - rprosperi - 05-16-2023 09:55 PM
RE: FORTH & HP: where to start? - floppy - 06-05-2023, 11:29 AM
RE: FORTH & HP: where to start? - KeithB - 05-17-2023, 02:27 PM
RE: FORTH & HP: where to start? - mfleming - 05-18-2023, 10:53 AM
RE: FORTH & HP: where to start? - mfleming - 05-18-2023, 09:54 PM
RE: FORTH & HP: where to start? - floppy - 05-20-2023, 02:00 PM
RE: FORTH & HP: where to start? - jonmoore - 05-29-2023, 02:42 AM
RE: FORTH & HP: where to start? - floppy - 06-05-2023, 07:52 PM



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