-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbinomial.vvm
50 lines (50 loc) · 937 Bytes
/
binomial.vvm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
PARAM "Input n: "
CALL out 1
CALL in 0 t0
PARAM t0
CALL to_int 1 t1
ASSIGN t1 sym_0_n
PARAM "Input m: "
CALL out 1
CALL in 0 t2
PARAM t2
CALL to_int 1 t3
ASSIGN t3 sym_0_m
JUMP L0
LABEL sym_0_f_factorial
ASSIGN param_0 sym_0_0_a
ASSIGN 1 sym_0_0_0_f
ASSIGN 2 sym_0_0_0_i
LABEL L1
LESSEQ sym_0_0_0_i sym_0_0_a t4
JUMPNIF t4 L2
MULT sym_0_0_0_f sym_0_0_0_i t5
ASSIGN t5 sym_0_0_0_f
PLUS sym_0_0_0_i 1 t6
ASSIGN t6 sym_0_0_0_i
JUMP L1
LABEL L2
RETURN sym_0_0_0_f
LABEL L0
JUMP L3
LABEL sym_0_f_binomial
ASSIGN param_0 sym_0_1_n
ASSIGN param_1 sym_0_1_m
SUB sym_0_1_n sym_0_1_m t9
PARAM t9
CALL sym_0_f_factorial 1 t10
PARAM sym_0_1_m
CALL sym_0_f_factorial 1 t11
MULT t11 t10 t8
PARAM sym_0_1_n
CALL sym_0_f_factorial 1 t12
DIV t12 t8 t7
RETURN t7
LABEL L3
PARAM sym_0_m
PARAM sym_0_n
CALL sym_0_f_binomial 2 t15
PLUS "Binomial (n m) : " t15 t14
PLUS t14 "\n" t13
PARAM t13
CALL out 1