Implement UEFI functionality in Forth
[rrq/jonasforth.git] / 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 Protocol. See
21 \ the UEFI specification and uefi.f for more information.
22 : BLUE-SQUARE
23   GraphicsOutputProtocol
24   HERE @ 255 C, 0 C, 0 C, 0 C, \ Buffer with single blue pixel
25   EfiBltVideoFill
26   0 0 \ Source
27   100 100 20 20 \ Destination
28   0
29   GOP.Blt() ;
30
31 HELLO
32 TEST-FIB
33 BLUE-SQUARE