9 main(int argc, char *argv[])
13 jit_state_t *frame_jit, *tramp_jit;
14 jit_node_t *arg, *done, *xfibs, *out, *ret1, *ret2;
17 _jit = frame_jit = jit_new_state();
23 jit_getarg(JIT_R1, arg);
25 /* Initialize language stack */
26 jit_movi(JIT_R0, (jit_word_t)stk);
27 jit_sti(&top, JIT_R0);
30 done = jit_movi(JIT_R0, 0);
38 jit_pushargi((jit_word_t)"xfibs(%d) = %d\n");
48 #define SIZE sizeof(jit_word_t)
49 _jit = tramp_jit = jit_new_state();
54 out = jit_blti(JIT_V0, 2);
55 jit_subi(JIT_V1, JIT_V0, 1); /* V1 = N-1 */
56 jit_subi(JIT_V2, JIT_V0, 2); /* V1 = N-2 */
58 /* save return address */
59 jit_ldi(JIT_R1, &top);
60 jit_stxi(SIZE * 0, JIT_R1, JIT_R0);
62 jit_stxi(SIZE * 1, JIT_R1, JIT_V0);
63 jit_stxi(SIZE * 2, JIT_R1, JIT_V1);
64 jit_stxi(SIZE * 3, JIT_R1, JIT_V2);
65 /* adjust "language" stack */
66 jit_addi(JIT_R1, JIT_R1, SIZE * 4);
67 jit_sti(&top, JIT_R1);
70 ret1 = jit_movi(JIT_R0, 0);
72 jit_movr(JIT_V0, JIT_V1);
74 jit_patch_at(jit_jmpi(), xfibs);
76 jit_movr(JIT_V1, JIT_V0); /* V1 = rfibs(N-1) */
78 jit_ldi(JIT_R1, &top);
79 jit_stxi(-SIZE * 2, JIT_R1, JIT_V1);
82 jit_ldxi(JIT_V2, JIT_R1, -SIZE * 1);
85 ret2 = jit_movi(JIT_R0, 0);
87 jit_movr(JIT_V0, JIT_V2);
89 jit_patch_at(jit_jmpi(), xfibs);
91 jit_movr(JIT_V2, JIT_V0); /* V2 = rfibs(N-2) */
93 /* reload return address */
94 jit_ldi(JIT_R1, &top);
95 jit_subi(JIT_R1, JIT_R1, SIZE * 4);
96 jit_ldxi(JIT_R0, JIT_R1, SIZE * 0);
98 jit_ldxi(JIT_V0, JIT_R1, SIZE * 1);
99 jit_ldxi(JIT_V1, JIT_R1, SIZE * 2);
100 /* V2 already loaded */
101 /* update "language" stack */
102 jit_sti(&top, JIT_R1);
104 jit_addi(JIT_V1, JIT_V1, 1);
105 jit_addr(JIT_V0, JIT_V1, JIT_V2);
113 address = jit_emit();