Reputation: 613
For our class, we had to make a C program that encodes MIPS instructions into instruction words and also decodes instruction words into MIPS instructions.
I wrote everything already and tested on some cases, but I wanted to test it on a bigger dataset.
We are given the test files: test.asm
and test.bin
.
The .asm
file has MIPS instructions and the .bin
file has the equivalent instruction words for those MIPS instructions.
My decode
function takes in the instruction words from test.bin
, converts them to equivalent MIPS instructions and sends it to stdout
.
I want to compare the output from my decode function with the MIPS instructions in the test.asm
file to see that they are equivalent (that I decoded correctly).
I was told that I could use the cmp
command with process substitution to compare the two but I don't know what I would put inside the <(...)
.
I run my program using: bin/mips -d < test.bin
where the -d
flag represents decoding
.
I was thinking maybe it would be like this, but I'm not sure:
cmp <(cat test.asm) <(bin/mips -d < test.bin)
Upvotes: 0
Views: 1120
Reputation: 782683
That command should work, but there's no need to use process substitution with cat
, just put the filename there:
cmp test.asm <(bin/mips -d < test.bin)
Upvotes: 4
Reputation: 17422
I'm not sure about using the format cmp file1 file2
, but you can do file1 | cmp file2
like this:
bin/mips -d test.bin | cmp test.asm
Upvotes: 2