Can't pass Fibonacciseries test

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Can't pass Fibonacciseries test

Anas1337
So my translator passed the simplefuntion and nestedcall tests but it couldn't pass the Fibonacci series test so the first thing i did is make my translator generate bootstrap code that sets SP to 256 and i also made it start with translating Sys.vm first but i still can't pass the test.
Thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: Can't pass Fibonacciseries test

cadet1620
Administrator
I'm assuming that you mean FunctionCalls/FibonacciElement test since that comes after FunctionCalls/NestedCall, not ProgramFlow/FibonacciSeries

NestedCall test is designed so that it can run with or without bootstrap code.
FibonacciElement and StaticsTest both require the boot strap.

The expected way to control bootstrap generation is based on the VMTranslator argument. If it is a file, do not generate the bootstrap. It the argument is a directory, generate the bootstrap. (This method is required if you are submitting your VMTranslator to the Coursera grader.)

Look at the the FibonacciElement.out file. If the RAM[0] (SP) value is 257 instead of 263, you are probably jumping to Sys.init instead of calling it. The boot code needs to write the asm code for "call Sys.init 0".

If you are not already doing so, write the VM source as comments in the generated ASM file. This will make it much easier to debug.
// if-goto IF_TRUE
    @SP
    AM=M-1
    D=M
    @Main.fibonacci$IF_TRUE
    D;JNE
// goto IF_FALSE
    @Main.fibonacci$IF_FALSE
    0;JMP
// label IF_TRUE          // if n<2, return n
(Main.fibonacci$IF_TRUE)
// push argument 0
    @ARG
    A=M
    D=M
    @SP
FibonacciElement is recursive and can be tough to debug.  If you need further help, you can email me your generated ASM files (with VM source comments, please) and I'll take a look at them.

--Mark