Yard/test.erpn

64 lines
727 B
Plaintext

extern function say_hello
extern function print
extern function println
extern function to_rat
extern function to_int
extern function parse_int
extern function parse_rat
fac:
Load Arg x
Load Int 1
NotEq Int
Unless
Load Int 1
Yield
Load Arg x
Load Int 1
Sub Int
Call fac
Load Arg x
Mul Int
Yield
number:
Load Rat 12.0
main:
Call number
Call to_int
Call fac
Store Int result
Load String "The Factorial of "
Call number
Load String " is: "
Load Var result
Cat Str
Cat Str
Cat Str
Call println
Load Int 0
Store Int x
Loopstart
Load Var x
Load Int 9
Gt Int
While
Load String ""
Load Var x
Cat Str
Call println
Load Var x
Load Int 1
Add Int
Store Int x
Load Int 0
Yield