snapshot before branching
[rrq/jonasforth.git] / lib / example.f
1 : FIB ( n -- Fn )
2   0 1                            ( n a b )
3   0                              ( n a b i )
4   BEGIN
5     ROT                          ( n i a b )
6     DUP ROT +                    ( n i b a+b )
7     ROT ROT                      ( n b a+b i )
8
9     1 +                          ( n b a+b i+1 )
10   DUP 4 PICK = UNTIL
11   DROP SWAP DROP SWAP DROP ;     ( a+b )
12
13 : HELLO S" Hello!" TELL NEWLINE ;
14
15 : TEST-FIB
16   S" 10 FIB = " TELL
17   10 FIB .U
18   SPACE S" (Expected: 59)" TELL NEWLINE ;
19
20 \ This example calls the Blt() function on UEFI's Graphics Output
21 \ Protocol. See the UEFI specification and uefi.f for more
22 \ information.
23 : BLUE-SQUARE
24   GraphicsOutputProtocol
25   HERE @ 255 C, 0 C, 0 C, 0 C, \ Buffer with single blue pixel
26   EfiBltVideoFill
27   0 0 \ Source
28   100 100 20 20 \ Destination
29   0
30   GOP.Blt() ;
31
32 HELLO
33 TEST-FIB
34 BLUE-SQUARE