Last active
September 8, 2021 12:59
-
-
Save ny-a/ba357492fe81f3712071d144897af939 to your computer and use it in GitHub Desktop.
SIMPLE でのフィボナッチ数列の算出
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// R0 output | |
// R1 constant(1) | |
// R2 temporary0 | |
// R3 temporary1 | |
// R4 counter | |
// Entrypoint: | |
// LI 0 0 | |
LI 1 1 | |
// LI 2 0 | |
LI 3 1 | |
LI 4 0 | |
// IN 4 | |
ADD 4 1 // do-while 的に --count == 0 で判定するため、1足しておく | |
//Loop: | |
MOV 0 2 | |
ADD 2 3 | |
SUB 4 1 | |
BE 5 // :End | |
MOV 0 3 | |
ADD 3 2 | |
SUB 4 1 | |
BE 1 // :End | |
B -9 // :Loop | |
//End: | |
// OUT 0 | |
// HLT | |
B -1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cf. https://oeis.org/A000045/list | |
$ for i in $(seq 0 23); do echo $i; java -jar SimpleSimulator.jar simple-fib.asm <<< $i; done | |
0 | |
Input? : output on 15 : 0 | |
1 | |
Input? : output on 15 : 1 | |
2 | |
Input? : output on 15 : 1 | |
3 | |
Input? : output on 15 : 2 | |
4 | |
Input? : output on 15 : 3 | |
5 | |
Input? : output on 15 : 5 | |
6 | |
Input? : output on 15 : 8 | |
7 | |
Input? : output on 15 : 13 | |
8 | |
Input? : output on 15 : 21 | |
9 | |
Input? : output on 15 : 34 | |
10 | |
Input? : output on 15 : 55 | |
11 | |
Input? : output on 15 : 89 | |
12 | |
Input? : output on 15 : 144 | |
13 | |
Input? : output on 15 : 233 | |
14 | |
Input? : output on 15 : 377 | |
15 | |
Input? : output on 15 : 610 | |
16 | |
Input? : output on 15 : 987 | |
17 | |
Input? : output on 15 : 1597 | |
18 | |
Input? : output on 15 : 2584 | |
19 | |
Input? : output on 15 : 4181 | |
20 | |
Input? : output on 15 : 6765 | |
21 | |
Input? : output on 15 : 10946 | |
22 | |
Input? : output on 15 : 17711 | |
23 | |
Input? : output on 15 : 28657 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment