Extremely Weird file comparison and pong replay

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

Extremely Weird file comparison and pong replay

Chamkey
Okay. New problem.

I'm never going to get the same @variableName assignations as the provided assembler because mine starts assigning from the 16th register while it seems as if, even though Simon has stated that the provided assembler starts assigning from the 16th register, it doesn't always do so.

For example in my Rect.hack I get: 0000000000010000 when I encounter @INFINITE_LOOP for the first time, whereas the provided assembler gives me 0000000000010111.
Not sure if this is going to be a problem when submitting to coursera.

But I have a larger issue at hand.
When the Pong.hack file that I generated from the provided assembler is compared to the Pong.hack that I created with my assembler, I get some startling results.
Attached below are the comparison and the actual lines.

Comparison:


Provided Assembler


My Assembler


As you can see, the assembler's results and mine are not all that different apart from the fact that on line 23115 and line 23119 mine and the assembler results are different.

Also when I run my hack code. I get the following:


which is disconcerting to say the least.

If anyone could please tell me what in the world I'm doing wrong because I have no clue.
If you would like to see my code I'll pm it to you.
Reply | Threaded
Open this post in threaded view
|

Re: Extremely Weird file comparison and pong replay

WBahn
Administrator
If your program involves multiple .jack (or .vm) files, then they are processed in whatever order they are encountered. The first variable IN THE FIRST FILE PROCESSED is assigned to RAM[16].
Reply | Threaded
Open this post in threaded view
|

Re: Extremely Weird file comparison and pong replay

ivant
In reply to this post by Chamkey
Chamkey wrote
For example in my Rect.hack I get: 0000000000010000 when I encounter @INFINITE_LOOP for the first time, whereas the provided assembler gives me 0000000000010111.
INFINITE_LOOP is probably a jump label in the code. In this case the assembler should find where it is defined, and assign the appropriate address to it.

It only assigns variables from 16 for strings that are neither predefined (e.g. R0 or SCREEN) nor labels defined in code like:
(INFINITE_LOOP)
Reply | Threaded
Open this post in threaded view
|

Re: Extremely Weird file comparison and pong replay

Chamkey
This post was updated on .
Thank you so much ivant and wbahn.

You're both my heroes. Without you two I'd probably still be stuck on the ALU.
It's funny just how far a little bit of advice really goes.

It works! I can't believe my assembler works. I literally just scrapped all the code that was doing any assigning and reworked where I was assigning the A instructions. I didn't expect it to work. I thought it would just give me another error prone file but it worked! When I did the file comparison I expected more red like in my first screenshot but I was pleasantly surprised.

I thank you from the bottom of my heart and hope y'all have a lovely Christmas.

Here's to hoping I can get more help from you in the future, if needed ;)