#include void main() { FILE *fp; int i, type; unsigned int address, instr; unsigned int masked_addr; // open trace file for reading fp = fopen("gcc_trace.txt", "r"); // read first 100 lines of trace file; // address holds virtual address in unsigned int format; // N.B. - your program must read all 1,000,000 lines but // you might want to test it on the first 100 lines // or so before running it on the entire trace file! for (i=0; i<100; ++i) { // read 1 line of trace file fscanf(fp, "%d %x %x", &type, &address, &instr); // example of bit-wise operation in C; // mask off all but the 2nd least significant hex digit, // shift right by 4 bits, and print address in hex and // masked shifted address in decimal masked_addr = (address & 0x000000f0) >> 4; printf("%8x %2d\n", address, masked_addr); } }