Commit | Line | Data |
---|---|---|
587afa38 EZ |
1 | ^ ->| | |
2 | Frame | | | | | |
3 | Number - | | |============| int fact (int n) | |
4 | | | | | i = 3 | { | |
5 | | | | |------------| if (0 == n) { | |
6 | | | | | f = ? | return 1; <-------- PC | |
7 | #4 main() < | | |------------| } | |
8 | | | | | | else { | |
9 | | | -+->|------------| ---> return n * fact (n - 1); | |
10 | | -+-+--+-----o | | } | |
11 | = | | |============| | } | |
12 | | | | | n = 3 | | | |
13 | | | | |------------| | main () | |
14 | #3 fact (3) < | | | o---------+- { | |
15 | | -+-+->|------------| | | int i; | |
16 | | | | --+-----o | | | | |
17 | = | | |============| | | for (i = 0; i < 10; i++) { | |
18 | | | | | n = 2 | | -> int f = fact (i); | |
19 | | | | |------------| | printf ("%d! = %d\n", i , f); | |
20 | #2 fact (2) < | | | o------+--| } | |
21 | | | | ->|------------| | } | |
22 | | | -+--+-----o | | | |
23 | = | | |============| | | |
24 | | | | | n = 1 | | | |
25 | | | | |------------| | | |
26 | #1 fact (1) < | | | o------+--| | |
27 | | | | |------------| | | |
28 | | ---|--+-----o |<-+------- FP | |
29 | = | |============| | | | |
30 | | | | n = 0 | | | | |
31 | | | |------------| | | | |
32 | #0 fact (0) < | | o--------- | | |
33 | | | |------------| | | |
34 | | --+-----o |<--------- SP | | |
35 | = |============| | | |
36 | | | Red Zone | v | |
37 | | \/\/\/\/\/\/\/ Direction of | |
38 | #-1 < \/\/\/\/\/\/\/ stack growth | |
39 | | | | |