comparing .hack files...best way?

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

comparing .hack files...best way?

krakerjak
This post was updated on .
I was trying to debug my completed assembler last week, which was performing perfectly assembling all test programs...except Pong.asm. I would assemble it with the supplied assembler, then with mine. I would import both hack files into excel because the compare function in the assembler was just too slow for 28k or so lines.

The comparison found 98 lines with "errors", or that didn't match. I was lost on what was going wrong until i looked at exactly what specific instruction these 98 errors were in the Pong.asm file. They ended up being A-instructions involving a set of about 5-6 different variables (ie. @ponggame.0).

What was originially thought to be an error in the assembler was really just my assembler storing the (correct) PC address to a slightly differing location in RAM. My hash table implementation populates slightly differently. Testing my output hack files works as expected in the hardware simulator, pong works as expected.

I was just thinking there could be a better way to confirm a working or proper output hack file from your own assembler. Testing vs. the output of another assembler varied in my case as implementation of hash table had a slight variation and mislead me to think i had coded a broken assembler.
Any thoughts?


Reply | Threaded
Open this post in threaded view
|

Re: comparing .hack files...best way?

cadet1620
Administrator
If you assign incrementing RAM addresses to undefined symbols as they are encountered during pass 2, as described in the text, you will get the same addresses and the supplied Pong.hack.

I ran into this same problem when I traversed my symbol table between passes and assigned addresses.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: comparing .hack files...best way?

krakerjak
ok i see what u mean.
im assigning a ram address in the first pass immediately as a variable, symbol or label is encountered and ignore duplicates....and if a symbol is added to the hash table, in the case where the proper label is defined later in the program, a corresponding label has priority and will update the value in the table to be that of the label.
Reply | Threaded
Open this post in threaded view
|

Re: comparing .hack files...best way?

gauze
In reply to this post by krakerjak
to answer the question in the subject line, on windows winmerge saved my ass as it can adapt for dos/unix carriage returns without prompting. regular old diff in linux was reporting tons of mismatched lines ... in fact all of them because of this difference.