사용자로부터 정수를 입력받아 재귀 호출로 피보나치 수를 계산하고 출력하는 MIPS 어셈블리 예제입니다.
Give a number:프롬프트를 출력합니다.- 정수를 입력받아
fib함수에 전달합니다. fib(0) = 0,fib(1) = 1을 종료 조건으로 재귀 계산합니다.- 계산된 값을 출력합니다.
fib.asm을 MARS 또는 QtSPIM과 같은 MIPS 시뮬레이터에서 열어 실행하세요.
A MIPS assembly example that reads an integer, calculates the corresponding Fibonacci number recursively, and prints the result.
- Print the
Give a number:prompt. - Read an integer and pass it to the
fibfunction. - Recurse using
fib(0) = 0andfib(1) = 1as base cases. - Print the calculated value.
Open and run fib.asm in a MIPS simulator such as MARS or QtSPIM.