\ edit_me.fs WIP
\ Tell the fybb.fs program where you've put it.
\ Tell it also where to find primes for RSA.
\ Version 2025-12-09, Copyright Gan Uesli Starling
\ License: None. Free for all uses.

S" D:/FYBB/"

\ EDIT THE ABOVE STRING to match where YOUR OWN copy of the FYBB directory is at.
\ Replace D:/FYBB with wherever. Must be a FULL path, 255 chars max.
\ Windows Example: C:/Users/Snowden/Desktop/FYBB
\ Linux Example: /home/snowden/forth/FYBB
\ Don't close the space after S" as spaces are Forth's essential delimiter.

S" D:/FYBB/primes50.txt"
S" D:/FYBB/primes50.txt"

\ EDIT THE ABOVE TWO STRINGS to match your own choice of two files from which
\ to read a pair of prime numbers for use as RSA keys. Can be both the same
\ file (as supplied), but recommend choosing two different. Obtain your own
\ pair of files from https://t5k.org/lists/small/millions/  Then unzip them,
\ just as they are, to anywhere, so long as pointed to correctly above.

\ Do you laugh at the primes being so small? Okay then, consider this. Each 
\ t5k.org file holds one million primes. And FYBB selects a DIFFERENT pair at
\ random for each re-scramble of its XOR key. Which event happens thousands 
\ of times each run. This intermixed with yet other key-scrambling algorithms.

\ DO NOTHING TO LINES BELOW. 

\ Copy a counted string
: cs.copy ( c-addr1 c1 c-addr2 -- )
  OVER OVER C!   ( c-addr1 c1 c-addr2 )  \ Store the count
  1+ SWAP CMOVE  ( )                     \ Chars follow after
;

: cs.append ( c-addr1 c1 c-addr2 c2 -- c-addr3 c3 )
  DUP PAD C!                 ( c-addr1 c1 c-addr2 c2 )
  2 PICK PAD C+!             ( c-addr1 c1 c-addr2 c2 ) \ Pad now has combined lengths
  2 PICK PAD + 1+ SWAP CMOVE ( c-addr1 c1 )            \ Right string on pad
  PAD 1+ SWAP CMOVE          ( )                       \ Left string on pad
  PAD COUNT                  ( c-addr3 c3 )            \ PAD addr & count        
;

CREATE _PRIMES2_ 256 ALLOT ALIGN
CREATE _PRIMES1_ 256 ALLOT ALIGN
_PRIMES2_ 256 BLANK
_PRIMES1_ 256 BLANK
_PRIMES2_ cs.copy
_PRIMES1_ cs.copy

CREATE _LOCAL_ 256 ALLOT ALIGN \ Storage location for path string
_LOCAL_ 256 BLANK              \ Initialize as all blank
_LOCAL_ cs.copy                \ Stores file path string where needed.

\ Combine a string with _LOCAL_ as path pre-pend and include it.
: include.file ( c-addr cnt )
  _LOCAL_ COUNT 2SWAP cs.append
  INCLUDED
;


