domenicodl
Programmer
Hello,
I have two files, namely file1 and file2 as follows
file1:
000020E0
000020E4
file2:
000020E0 3D 20 00 40 lis r9,400000
000020E4 39 29 A0 00 addi r9,-6000
000020E8 80 09 00 00 lwz r0,00(r9)
000020EC 7C 03 03 78 mr r3,r0
000020F0 81 61 00 00 lwz r11,00(r1)
I want to take the lines in file1 compare them with the first field of each line of file2 and if they are equals do some processing on the line (of the file2)
for example, I take the first line in file1, 000020E0 I compare it with 000200E0 in the second file, they are equals thenn I take some fields from this line and I do some processing.
I wrote the following script:
BEGIN { print "PARSER"}
#open the first file.
NR==FNR{
pc[NR] = $1; #pc is the first field in file 1
number_of_pc = NR;
next;
}
#reading of the first file finished.
#Starting with the second one
{
pc_disass = $1;
instruction = $6;
register = $7;
#compare each line in file1 (the pc array) with
the first field of the current line in file2 (pc_dissass)
for( i = 1; i == number_of_pc; i++ )[
if ( pc_disass == pc)
print pc_disass;
}
next;
}
END {print "- DONE -"}
I do not know why the for loop is never executed albeit it is written correctly.
Thank you in advance.
I have two files, namely file1 and file2 as follows
file1:
000020E0
000020E4
file2:
000020E0 3D 20 00 40 lis r9,400000
000020E4 39 29 A0 00 addi r9,-6000
000020E8 80 09 00 00 lwz r0,00(r9)
000020EC 7C 03 03 78 mr r3,r0
000020F0 81 61 00 00 lwz r11,00(r1)
I want to take the lines in file1 compare them with the first field of each line of file2 and if they are equals do some processing on the line (of the file2)
for example, I take the first line in file1, 000020E0 I compare it with 000200E0 in the second file, they are equals thenn I take some fields from this line and I do some processing.
I wrote the following script:
BEGIN { print "PARSER"}
#open the first file.
NR==FNR{
pc[NR] = $1; #pc is the first field in file 1
number_of_pc = NR;
next;
}
#reading of the first file finished.
#Starting with the second one
{
pc_disass = $1;
instruction = $6;
register = $7;
#compare each line in file1 (the pc array) with
the first field of the current line in file2 (pc_dissass)
for( i = 1; i == number_of_pc; i++ )[
if ( pc_disass == pc)
print pc_disass;
}
next;
}
END {print "- DONE -"}
I do not know why the for loop is never executed albeit it is written correctly.
Thank you in advance.