Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function Fib.fib ( n ) in Hack VM code to calculate the n - th Fibonacci number recursively. Complete the code in Fib.vm
Write a function Fib.fib n in Hack VM code to calculate the nth Fibonacci number recursively. Complete the code in Fib.vm Where: Fib.fib is the name of the function n is which number in the Fibonacci sequence to calculate, Where: Fib.fib Fib.fib The call command for this function is provided in a separate file See Sysvm Test Cases: Write at least test cases. A sample test case is provided in Fibtst Each test case should be in a file named FibXX.tst where XX is a number starting at You should also submit any supporting files, such as CMP files. Your mark for this task may be scaled down for poormissing testing. Fib.vm: Contains a function Fib.fib that calculates and returns the nth Fibonacci number recursively n is supplied as an argument Put your code here. Fibtst: Sample Test file for ArrSort.asm Follows the Test Scripting Language format described in Appendix B of the book "The Elements of Computing Systems" load, outputfile Fibout, compareto Fibcmp outputlist spD localD argumentD thisD thatD RAMD RAMD RAMD localD localD localD argumentD argumentD argumentD; set sp stack pointer set local base address of the local segment set argument base address of the argument segment set this base address of the this segment set that base address of the that segment set RAM static set RAM static set RAM static set local local set local local set local local set argument argument set argument argument set argument; argument repeat Change this number to cover the number of instructions in the VM test file vmstep; output; Fibcmp: sp local argument this that RAMRAMRAM local local local argument argument argument Sysvm: Runs x Fib.fiby x & y are static variables function Sysinit push static call Fib.fib pop static label END goto END
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started