Commit | Line | Data |
---|---|---|
4a71579b PC |
1 | .data 32 |
2 | fmt: | |
3 | .c "nfibs(%d) = %d\n" | |
4 | ||
5 | .code | |
6 | jmpi main | |
7 | ||
8 | name rfibs | |
9 | rfibs: | |
10 | prolog | |
11 | arg $in | |
12 | getarg %r0 $in /* R0 = N */ | |
13 | beqi out %r0 0 | |
14 | movr %v0 %r0 /* V0 = R0 */ | |
15 | movi %r0 1 | |
16 | blei_u out %v0 2 | |
17 | subi %v1 %v0 1 /* V1 = N-1 */ | |
18 | subi %v2 %v0 2 /* V1 = N-2 */ | |
19 | prepare | |
20 | pushargr %v1 | |
21 | finishi rfibs | |
22 | retval %v1 /* V1 = rfibs(N-1) */ | |
23 | prepare | |
24 | pushargr %v2 | |
25 | finishi rfibs | |
26 | retval %r0 /* R0 = rfibs(N-2) */ | |
27 | addr %r0 %r0 %v1 | |
28 | out: | |
29 | retr %r0 | |
30 | epilog | |
31 | ||
32 | name main | |
33 | main: | |
34 | prolog | |
35 | prepare | |
36 | pushargi 32 | |
37 | finishi rfibs | |
38 | retval %v0 | |
39 | prepare | |
40 | pushargi fmt | |
41 | ellipsis | |
42 | pushargi 32 | |
43 | pushargr %v0 | |
44 | finishi @printf | |
45 | ret | |
46 | epilog |