\  Test case of a branch going over too large a range for eight-bit offsets
\  Body generated by the "Verbal Bottles of Beer" script,
\ (Verbal argument of 1 is enough to do it.)
\  Also a branch that goes over too large a range even for sixteen-bit offsets.
\ (Verbal argument of 179 is just enough to do that.)
\ (Verbal argument of N >= 180 exceeds all the branch ranges.)
\  Command-line definition of 'fld_cmd' can be used to load variable-sized bodies
\  and should be of the form 'fload <filename>' .


fcode-version1          \  Eight-bit offsets.

headers

: too-large-case ( n -- )

    ." Let's give it a large back-reference too."
    begin  ." We've just begun"
     ." 1 0 do " cr 1 0 do
    dup  ." if " cr
    if
        dup ." case"
	case
	0 of  ."  Just a short case" cr endof
	." default.  The Big One!" cr

    fload  TooLargeBranch_off08_body.fth

        endcase
    ." then"
    then
       ." Loop back and forward" cr loop

   ."  And here we are!"
   exit
   ."  Well, we needed some way out!"

    again  ."  Back to the fuchsia."
;

\  Let's make a small jump, just to see what normal looks like
: control-example
      ."  Here's the beguine"
 begin
    dup  ." if "
    if
        dup ." case"
	case
	0 of  ."  Short case" cr endof
	."  No default." cr
        endcase
    ." then"
    then

       ." Way out"
   exit
       ." Jump back"
    again   ."  Never do this"
;


\  Let's make a do-loop that straddles the limit
\  (I.e., the "outer" branch is just too large,
\      but the "inner" branch just fits.)
: straddle-loop
    ." 1 0 do" cr  1 0 do

." Take it down and pass it around..." cr
." How dry I am!  How dry I am!" cr
." No body knows" cr
." How ... Dry I ... Aaaammm."  cr

    ." Loop." cr  loop
    ." Here we go!" cr
;

\  Here's the do-loop that can overflow even sixteen-bit offsets.

: too-large-case ( n -- )

    ." Let's give it a large back-reference too."
    begin  ." We've just begun"
     ." 1 0 do " cr 1 0 do
    dup  ." if " cr
    if
        dup ." case"
	case
	0 of  ."  Just a short case" cr endof
	." Not my default!  A Big One!" cr

[ifndef] fld_cmd
    fload  TooLargeBranch_off16_body.fth
[else]
    [defined] fld_cmd
[endif]

        endcase
    ." then"
    then
       ." Loop back and forward" cr loop

   ."  And here we are!"
   exit
   ."  Well, we needed some way out!"

    again  ."  Back to the fuchsia."
;

fcode-end
