CASLファイルの整理
[YACASL2.git] / as / app / fib / fib.casl
1 ;;; 入力 GR1:整数
2 ;;; 出力 GR0:フィボナッチ数
3 FIB     START
4         PUSH    0,GR1
5         PUSH    0,GR2
6         PUSH    0,GR3
7         LAD     GR0,0           ; フィボナッチ数
8         LAD     GR2,0           ; インデックス
9 LOOP    CPA     GR2,GR1
10         JZE     FIN
11         LAD     GR3,SEQ,GR2
12         AND     GR2,GR2
13         CPA     GR2,=1
14         JPL     O2
15         LAD     GR0,1
16         JUMP    STSEQ
17 O2      LD      GR0,-2,GR3
18         ADDL    GR0,-1,GR3
19 STSEQ   ST      GR0,0,GR3
20         LAD     GR2,1,GR2
21         JUMP    LOOP
22 FIN     POP     GR3
23         POP     GR2
24         POP     GR1
25         RET
26 SEQ     DS      24
27         END