Help required in VMTranslator

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

Help required in VMTranslator

Stormtrooper2001
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Help required in VMTranslator

WBahn
Administrator
Have you looked at the assembly code output that your translator produces for a call command and then walked through it manually to see what it does compared to what you need it to do?
Reply | Threaded
Open this post in threaded view
|

Re: Help required in VMTranslator

Stormtrooper2001
yes the code pushes some values on to the stack and jumps to the code. The assembly level code also looks fine to me.
These are my generated output files.
1.NestedCall.asm2.FibonacciElement.asm3.StaticsTest.asm
Reply | Threaded
Open this post in threaded view
|

Re: Help required in VMTranslator

WBahn
Administrator
Have you walked through the return part?

Try writing an extremely simple program that defines a function that does nothing but return the single value that is passed to it. Then at the top of the code (outside a function -- so you need to supply the bootstrap code in the test file) you simply call that function and go into an infinite loop once it returns.

So perhaps

push constant 42
call myTest 1
label TheEnd
goto TheEnd

function myTest 0
push argument 0
return

It's been awhile since I've written VM code, so be sure that the above makes sense and doesn't have any silly errors in it.
Reply | Threaded
Open this post in threaded view
|

Re: Help required in VMTranslator

Stormtrooper2001
Yes, your code works well it didn't have any issues. Also I don't think the issue is with the function or return commands as the file SimpleFunction.vm file executes perfectly. So the issue has to be with the call command only. But as far as I have debugged it, it looks fine to me.fn.asm this is the asm of your code.
Reply | Threaded
Open this post in threaded view
|

Re: Help required in VMTranslator

Stormtrooper2001
In reply to this post by WBahn
update: I got my code to work on NestedCall. I reuploaded week 7 and found out there was an issue also in my function call I replaced push(f, local, i) with push(f, constant,0) as my code was only pushing the Stack pointer by nargs values and not assigning them to 0, still struggling to do FibboncciElement and Staics Test