I have been working so hard for over a 2 Weeks but

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

I have been working so hard for over a 2 Weeks but

Ameeno
I am finding it impossible for all the tests to pass for excercise 8.

I have even resorted to re-writing everything multiple times,

looking on github for others solutions (which seem to be broken too)

and i have gone back to excercise 7, regressed on my excercise 7 code and test it all (ALL of it passed excercise 7 tests)

and rewrote the functions call/return/function, if, goto & label.

but i am on the verge of giving up and simply skipping the project.

However as a last ditch effort, can you please please help me find the bug in my code?

here is the shared folder (i will remove it in a few days)
https://drive.google.com/open?id=1xuBNRcRy0QpTTElV1nma7ojPpumhgpYq

Please help :) thanks.!
Reply | Threaded
Open this post in threaded view
|

Re: I have been working so hard for over a 2 Weeks but

WBahn
Administrator
Focus on one thing at a time. Don't write all of the functions and then see if they pass the tests -- that leaves you with a lot of code without anyway of knowing where to start looking (that's not quite true, but close).

Implement the label command and write a couple of simple VM code fragments that use a few labels and then run your translator on it and look at the resulting assembly code file. Does it do it right?

Then implement the goto command and do the same thing.

Then implement the if-goto command and do the same thing.

Then run test these using the authors' supplied programs.

Don't even worry about the function, call, and return commands until you pass these tests.

If it doesn't pass the tests, don't just go banging away at your code hoping that if you make some changes it will happen to pass the next time. Look at the translated code and figure out what it did that it shouldn't have (or didn't do that it should have) and THEN look at your code and be sure you understand why your code generated the wrong thing. That way you know what needs to be fixed.
Reply | Threaded
Open this post in threaded view
|

Re: I have been working so hard for over a 2 Weeks but

Ameeno
Ok Great stuff, SO i tested the Program flow tests (WIthout write init) and it works fine.

DO you think introducing writeinit fails the Program flow tests?

or is there a problem in my Call code?
Reply | Threaded
Open this post in threaded view
|

Re: I have been working so hard for over a 2 Weeks but

Ameeno
still finding it really really hard, I am missing something major it seems.
Reply | Threaded
Open this post in threaded view
|

Re: I have been working so hard for over a 2 Weeks but

ivant
In reply to this post by Ameeno
Ameeno wrote
Ok Great stuff, SO i tested the Program flow tests (WIthout write init) and it works fine.

DO you think introducing writeinit fails the Program flow tests?

or is there a problem in my Call code?
Yes, as the book describes, the tests BasicLoop, Fibonacci and SimpleFunction expect that the Sys.init code is not implemented yet, so the tests do the initialization. On the other hand FibonacciElement and StaticTest expect that Sys.init is already implemented.

There is a newer test, NestedCall, that is not described in the book. You should implement it after SimpleFunction, but before FibonacciElement. Read NestedCall.html for more info.

It's a good idea to add a switch to your compiler whether to generate the bootstrap code or not. It's only useful during these tests, but it's still makes life easier to have it. Just make sure the default is to generate it.
Reply | Threaded
Open this post in threaded view
|

Re: I have been working so hard for over a 2 Weeks but

Ameeno
Well, chaps,

Based on that new found insight,

It seems my code is working flawlessly and I have been refactoring and refactoring for over 3 weeks on and off for no reason,

Oh well, at least I am getting coding practice :)
Reply | Threaded
Open this post in threaded view
|

Re: I have been working so hard for over a 2 Weeks but

Lozminda
In reply to this post by Ameeno
I'm still on project 7 after six weeks (I am self employed, which is really wrecking my coding time) so don't feel bad. The advice is good about breaking things down into smaller problems and not trying to do it all in one go.

I'm also learning C, malloc and "string" handling has been driving me bonkers on this particular project.

You've got this far, am sure you'll succeed !

Another good tip, (well it's worked for me) if it's late and you're not getting anywhere, do something else, non computer related or even go to sleep if you have the time, sometimes this helps to: "move a mental block" or " helps with an insight".

All the best and good luck (sometimes a lucky break does help, despite all the sensible analysis)

Lozminda