Hack file format

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

Hack file format

ChaosLearner
This post was updated on .
Hello,
I was wondering if there is a specific end of line character to use when generating the binary files.

I got the message " comparison failure : Line 0".

I cant find the difference between my result and the expected one.

EDIT : I added the Add.hack to help compare
Add.hack

 

A zoomed image :



Reply | Threaded
Open this post in threaded view
|

Re: Hack file format

WBahn
Administrator
If I get a chance, I'll run some tests later to explore this.

In the meantime, try producing files having both LF and CRLF EOL sequences and see which, if either, pass.

It's also possible that your assembler is embedding characters that are hidden and that that is what is causing the problem. You might write a little script to print out the actual bytes in your file so that you can see what is actually there.

If you don't have the ability to manipulate files at the byte level, check the exact length of one of your files and determine how many bytes there are per line of text. Should be either 17 or 18. If it's more than that, then there are hidden characters.

You can also upload one of your .hack files here and we can examine it for you.
Reply | Threaded
Open this post in threaded view
|

Re: Hack file format

WBahn
Administrator
In reply to this post by ChaosLearner
Your file uses Windows EOL sequences (CR-LF).

The file produced by the online IDE uses Unix EOL sequences (LF).

I converted your file to Unix and it passed the comparison.

I'll pass this along to the authors, as the tools should make an effort to be agnostic about EOL sequences.

If you don't already have a way to convert them, one simple way is to download and install Notepad++. Then open the file and in the lower-right on the status bar you will see what the line ending is that was detected. You can click this and pick a different line ending. Save the file, and you are done.

I'm sure there are online tools to do the same thing.
Reply | Threaded
Open this post in threaded view
|

Re: Hack file format

song
In reply to this post by ChaosLearner
I had the same problem.

thank you!!

you can also do this by VSCODE
Reply | Threaded
Open this post in threaded view
|

Re: Hack file format

ChaosLearner
In reply to this post by WBahn
Thank you for your answer.
I ended up uploading the file on the coursera web site and the test passed there.

I tried your solution and it does work in the web IDE to change the EOL sequence.