Note that I posted this thread earlier, I'm reposting because the issue has evolved some and I have a clearer idea of what the problem is.

I'm trying to resolve a segmentation fault that occurs in the traversal of a string array. My code is doing the following:

- open a file
- read hex strings from binary file compiled from simple c++ program
- filter out any strings that are not 8 bits long (everything else is garbage)
- convert strings to decimal representation of hex string
- load decimal values into array to be used by Verilog module

The rest is erroneous.

Here is my code:

#include "VMIPS.h"
#include "VMIPS_MIPS.h"//required to explicitly access signals from submodules
#include <verilated.h> 
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <vector>
using namespace std;

void outputLine( const string );
static inline int hexCharValue(char);

string array[274815];
unsigned int main_time = 0;
int i=0;
int k=0;//used for sorted array augmentation
int z = 0;//used for stream in counter
int main(int argc, char **argv) 
{
        //define local variables/arrays
        int temp;//hex conversaion accumulator
        string Hex;//dump variable for stream in
        
        //define objects
        ifstream inClientFile( "DAN_FILE.txt",ios::in );//stream in object
        Verilated::commandArgs(argc, argv);
	VMIPS *top = new VMIPS;
	top->CLK = 0;
        
        //popen();
        
        //test if instruction file can be opened
        if ( !inClientFile )
        {
            cerr << "File couldn't be opened" << endl;
            exit( 1 );
        }

        //fill string array with all file values and determines length of program
        while ( inClientFile >> Hex )
        {
            //fills array[..] with strings
            outputLine( Hex );
            i++;
        }

        z = i;
        cout << "Z:" << z << endl;
        int DataMem[z];
        int InstructionMemory[z];
        string tempInstructionMemory[z];

        //cut out undesired strings from array
        int u = 0;
        for(i=0;i<z;i++)
        {
                if ((array[i].length() == 8)&&((array[i].find("fs24")!=1)&&(array[i].find("f0")!=1)))
                {
                        tempInstructionMemory[k] = array[i];
                        k++;
                }
                else
                {
                     u++;   
                }
        }

        //convert string hex to numerical decimal
        for( int j=0;j<=z-u-1;j++ )//(z-u);j++ )//(z-u);j++ )//(z-u);j++ )
        {
                for( int y=7;y>=0;y--)
                {
                        InstructionMemory[j]+=hexCharValue(tempInstructionMemory[j][y])<<(4*(7-y));
                }
                temp = 0;
                //out << "Index:" << j << " HEX:" << tempInstructionMemory[j] << " DEC:" << InstructionMemory[j]<<endl;
        }

        //MIPS I processor interface
	while (!Verilated::gotFinish()) 
	{	
		
		top->CLK=!(top->CLK);
                top->Iin = InstructionMemory[top->Iaddr];
                top->eval();
                top->Din = DataMem[top->Daddr];
                DataMem[top->Daddr] = top->Dout;
		main_time++;
                printf("PCOut:%d",top->v->__PVT__PCout);//example of inner register access
                //printf("\nIaddr:%d Iin:%d CLK:%d Time:%d",top->Iaddr,top->Iin,top->CLK,main_time);
		if(top->CLK)
                {
                    printf("(%d)\n****************************************\n",main_time);
                }
                if(main_time>9)
		{
			printf("\n********** Complete **********\n\n");
			return 0;
		}
	}

        return 0;
}
//stream in helper function
void outputLine( const string Hex )
{
        array[i] = Hex;
}
//hex conversion helper function
static inline int hexCharValue(char ch)
{
    if (ch>='0' && ch<='9')return ch-'0';
    if (ch>='a' && ch<='f')return ch-'a'+10;
    return 0;
}
/*
 ***** Root Command Call *****

cd Desktop && cd verilator-3.802 && export VERILATOR_ROOT=//Users/dansnyder/Desktop/verilator-3.802 && cd test_MIPS && $VERILATOR_ROOT/bin/verilator --cc MIPS.v --exe sim_main.cpp && cd obj_dir/ && make -j -f VMIPS.mk VMIPS && cd .. && obj_dir/VMIPS && cd .. && cd .. && cd ..

*/

So the issue seems to be occurring at line 77. This line converts string hex numbers to decimal integers. If one were to spell out this line (which is how I originally had done it.) the code would be the following:

if( tempInstructionMemory[j].at(y) ==  '0' ) temp = (0*pow(16.,(int)(7-y)));
else if( tempInstructionMemory[j].at(y) ==  '1' ) temp = (1*pow(16.,(int)(7-y)));
else if( tempInstructionMemory[j].at(y) ==  '2' ) temp = (2*pow(16.,(int)(7-y)));
else if( tempInstructionMemory[j].at(y) ==  '3' ) temp = (3*pow(16.,(int)(7-y)));
else if( tempInstructionMemory[j].at(y) ==  '4' ) temp = (4*pow(16.,(int)(7-y)));
else if( tempInstructionMemory[j].at(y) ==  '5' ) temp = (5*pow(16.,(int)(7-y)));
else if( tempInstructionMemory[j].at(y) ==  '6' ) temp = (6*pow(16.,(int)(7-y)));
else if( tempInstructionMemory[j].at(y) ==  '7' ) temp = (7*pow(16.,(int)(7-y)));
else if( tempInstructionMemory[j].at(y) ==  '8' ) temp = (8*pow(16.,(int)(7-y)));
else if( tempInstructionMemory[j].at(y) ==  '9' ) temp = (9*pow(16.,(int)(7-y)));
else if( tempInstructionMemory[j].at(y) ==  'a' ) temp = (10*pow(16.,(int)(7-y)));
else if( tempInstructionMemory[j].at(y) ==  'b' ) temp = (11*pow(16.,(int)(7-y)));
else if( tempInstructionMemory[j].at(y) ==  'c' ) temp = (12*pow(16.,(int)(7-y)));
else if( tempInstructionMemory[j].at(y) ==  'd' ) temp = (13*pow(16.,(int)(7-y)));
else if( tempInstructionMemory[j].at(y) ==  'e' ) temp = (14*pow(16.,(int)(7-y)));
else if( tempInstructionMemory[j].at(y) ==  'f' ) temp = (15*pow(16.,(int)(7-y)));
InstructionMemory[j]=InstructionMemory[j]+temp;

Now, if I comment out the lines 5 and 11 I no longer get the segfault. If I change the argument of the pow function to anything between 0-5 and 8+ then the seg fault doesn't occur either. Any ideas?

Recommended Answers

All 15 Replies

Line 46 says fills array with hex but you are not actually doing that. Could be your problem

As far as I understand my comment is correct. Could you elaborate please?

sorry did realize the array was global. I thought it was part of main.

Can you provide some test data set (the smaller the better) which exhibits the seg fault?

Here is a very small excerpt from the binary file hex dump that I'm reading.

{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf290
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\margl1440\margr1440\vieww25480\viewh18700\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural

\f0\fs24 \cf0   0x00400130 3c1c1002 279ca240 0000f821 3c040040 <...'..@...!<..@\
  0x00400140 24840348 8fa50000 27a60004 3c01ffff $..H....'...<...\
  0x00400150 3421fff8 03a1e824 27bdffe0 3c070040 4!.....$'...<..@\
  0x00400160 24e700f8 3c08004b 2508b148 afa80010 $...<..K%..H....\
  0x00400170 afa20014 0c112298 afbd0018 1000ffff ......".........\
  0x00400180 00000000 00000000 00000000 00000000 ................\
  0x00400190 27bdffe8 3c020000 24420000 10400003 '...<...$B...@..\
  0x004001a0 afbf0010 0040f809 00000000 8fbf0010 .....@..........\
  0x004001b0 03e00008 27bd0018 00000000 00000000 ....'...........\
  0x004001c0 3c021001 90422440 27bdffe8 14400018 <....B$@'....@..\
  0x004001d0 afbf0010 3c021000 8c420014 8c430000 ....<....B...C..\
  0x004001e0 10600009 24420004 3c011000 0060f809 .`..$B..<....`..\
  0x004001f0 ac220014 3c021000 8c420014 8c430000 ."..<....B...C..\
  0x00400200 1460fff9 24420004 3c020044 24427714 .`..$B..<..D$Bw.\
  0x00400210 50400005 24020001 3c041000 0040f809 P@..$...<....@..\
  0x00400220 24842910 24020001 3c011001 a0222440 $.).$...<...."$@\
  0x00400230 8fbf0010 03e00008 27bd0018 27bdffe8 ........'...'...\
  0x00400240 afbf0010 8fbf0010 03e00008 27bd0018 ............'...\
  0x00400250 27bdffe8 3c020044 2442748c 3c041000 '...<..D$Bt.<...\
  0x00400260 24842910 3c051001 24a52444 10400003 $.).<...$.$D.@..\
  0x00400270 afbf0010 0040f809 00000000 3c041001 .....@......<...\
  0x00400280 24842244 8c820000 10400008 8fbf0010 $."D.....@......\
  0x00400290 3c020000 24420000 10400004 00000000 <...$B...@......\
  0x004002a0 0040f809 00000000 8fbf0010 03e00008 .@..............\
  0x004002b0 27bd0018 27bdffe8 afbf0010 8fbf0010 '...'...........\
  0x004002c0 03e00008 27bd0018 00000000 00000000 ....'.....

>> which exhibits the seg fault

Are you sure a segfault is reproducible with this set?

I'm not positive about this segment causing an issue. First lets make sure that I posted the correct cpp. Here's the most up to date code and this definitely causes a seg fault:

#include "VMIPS.h"
#include "VMIPS_MIPS.h"//required to explicitly access signals from submodules
#include <verilated.h> 
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <vector>
using namespace std;

void outputLine( const string );
static inline int hexCharValue(char);

char filename[50];
string array[274815];
unsigned int main_time = 0;
int i=0;
int k=0;//used for sorted array augmentation
int z = 0;//used for stream in counter
bool open = false;

int main(int argc, char **argv) 
{
        //define local variables/arrays
        int temp;//hex conversaion accumulator
        int letter;
        string Hex;//dump variable for stream in
        
        //define objects
        ifstream inClientFile( "DAN_FILE.txt",ios::in );//stream in object
        Verilated::commandArgs(argc, argv);
	VMIPS *top = new VMIPS;
	top->CLK = 0;
        FILE *fp;
        //popen();
        
        //test if instruction file can be opened
        if ( !inClientFile )
        {
            cerr << "File couldn't be opened" << endl;
            exit( 1 );
        }

        //fill string array with all file values and determines length of program
        while ( inClientFile >> Hex )
        {
            //fills array[..] with strings
            outputLine( Hex );
            i++;
        }

        z = i;
        cout << "Z:" << z << endl;
        int DataMem[z];
        int InstructionMemory[z];
        string tempInstructionMemory[z];

        //cut out undesired strings from array
        int u = 0;
        for(i=0;i<z;i++)
        {
                if ((array[i].length() == 8)&&((array[i].find("fs24")!=1)&&(array[i].find("f0")!=1)))
                {
                        tempInstructionMemory[k] = array[i];
                        k++;
                }
                else
                {
                     u++;   
                }
        }

        //convert string hex to numerical decimal
        for( int j=0;j<=z-u-1;j++ )//(z-u);j++ )//(z-u);j++ )//(z-u);j++ )
        {
                for( int y=7;y>=0;y--)
                {
                        InstructionMemory[j]+=hexCharValue(tempInstructionMemory[j][y])<<(4*(7-y));
                }
                temp = 0;
                //out << "Index:" << j << " HEX:" << tempInstructionMemory[j] << " DEC:" << InstructionMemory[j]<<endl;
        }

        //MIPS I processor interface
	while (!Verilated::gotFinish()) 
	{	
		
		top->CLK=!(top->CLK);
                top->Iin = InstructionMemory[top->Iaddr];
                top->eval();
                top->Din = DataMem[top->Daddr];
                DataMem[top->Daddr] = top->Dout;
		main_time++;
                printf("PCOut:%d",top->v->__PVT__PCout);//example of inner register access
                //printf("\nIaddr:%d Iin:%d CLK:%d Time:%d",top->Iaddr,top->Iin,top->CLK,main_time);
                
                //time stamp
		if( top->CLK )
                {
                    printf("(%d)\n****************************************\n",main_time);
                }
                if(main_time>9)
		{
                    printf("\n********** Complete **********\n\n");
                    return 0;
		}
                
                //SYSCAL
                if ( top->Iin == 3690987584 )//exit 1
                {
                    cout << "Exit" << endl;
                    return 0;
                }
                else if ( ( top->Iin == 3690987776 ) | ( open == true ) )//open 4
                {
                    if ( open == false )
                    {   
                        cout << "Enter file name: ";
                        cin >> filename;
                        cout << endl;
                        open = true;
                        fp = fopen(filename,"rb");
                        if( ( fp = fopen( "my.txt", "r")) == NULL)
                            puts("Cannot oepn the file");
                    }
                    else
                    {
                        if ( top->Iin ==  3690987648 )//read 2
                        {
                            while( ( letter = fgetc( fp ) ) != EOF)
                                printf("%c",letter);
                        }
                        else if ( top->Iin ==  3690987712 )//write 3
                        {
                            char input[1000];
                            cout << "Enter input to stream:";
                            fgets (input,999,stdin);
                            fputs (input,fp);
                        }
                    }
                }
                else if ( top->Iin == 3690987840 )//close 5
                {
                    fclose( fp );
                    open = false;
                }
                else if ( top->Iin == 3690987904 )//time 6
                {
                    cout << "Time:" << main_time << endl;
                }
	}

        return 0;
}
//stream in helper function
void outputLine( const string Hex )
{
        array[i] = Hex;
}
//hex conversion helper function
static inline int hexCharValue(char ch)
{
    if (ch>='0' && ch<='9')return ch-'0';
    if (ch>='a' && ch<='f')return ch-'a'+10;
    return 0;
}
/*
 ***** Root Command Call *****

cd Desktop && cd verilator-3.802 && export VERILATOR_ROOT=//Users/dansnyder/Desktop/verilator-3.802 && cd test_MIPS && $VERILATOR_ROOT/bin/verilator --cc MIPS.v --exe sim_main.cpp && cd obj_dir/ && make -j -f VMIPS.mk VMIPS && cd .. && obj_dir/VMIPS && cd .. && cd .. && cd ..

*/

And I'll include a larger swatch of data:

{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf290
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\margl1440\margr1440\vieww25480\viewh18700\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural

\f0\fs24 \cf0   0x00400130 3c1c1002 279ca240 0000f821 3c040040 <...'..@...!<..@\
  0x00400140 24840348 8fa50000 27a60004 3c01ffff $..H....'...<...\
  0x00400150 3421fff8 03a1e824 27bdffe0 3c070040 4!.....$'...<..@\
  0x00400160 24e700f8 3c08004b 2508b148 afa80010 $...<..K%..H....\
  0x00400170 afa20014 0c112298 afbd0018 1000ffff ......".........\
  0x00400180 00000000 00000000 00000000 00000000 ................\
  0x00400190 27bdffe8 3c020000 24420000 10400003 '...<...$B...@..\
  0x004001a0 afbf0010 0040f809 00000000 8fbf0010 .....@..........\
  0x004001b0 03e00008 27bd0018 00000000 00000000 ....'...........\
  0x004001c0 3c021001 90422440 27bdffe8 14400018 <....B$@'....@..\
  0x004001d0 afbf0010 3c021000 8c420014 8c430000 ....<....B...C..\
  0x004001e0 10600009 24420004 3c011000 0060f809 .`..$B..<....`..\
  0x004001f0 ac220014 3c021000 8c420014 8c430000 ."..<....B...C..\
  0x00400200 1460fff9 24420004 3c020044 24427714 .`..$B..<..D$Bw.\
  0x00400210 50400005 24020001 3c041000 0040f809 P@..$...<....@..\
  0x00400220 24842910 24020001 3c011001 a0222440 $.).$...<...."$@\
  0x00400230 8fbf0010 03e00008 27bd0018 27bdffe8 ........'...'...\
  0x00400240 afbf0010 8fbf0010 03e00008 27bd0018 ............'...\
  0x00400250 27bdffe8 3c020044 2442748c 3c041000 '...<..D$Bt.<...\
  0x00400260 24842910 3c051001 24a52444 10400003 $.).<...$.$D.@..\
  0x00400270 afbf0010 0040f809 00000000 3c041001 .....@......<...\
  0x00400280 24842244 8c820000 10400008 8fbf0010 $."D.....@......\
  0x00400290 3c020000 24420000 10400004 00000000 <...$B...@......\
  0x004002a0 0040f809 00000000 8fbf0010 03e00008 .@..............\
  0x004002b0 27bd0018 27bdffe8 afbf0010 8fbf0010 '...'...........\
  0x004002c0 03e00008 27bd0018 00000000 00000000 ....'...........\
  0x004002d0 27bdffe0 3403ffff afb10014 afb00010 '...4...........\
  0x004002e0 afbf0018 00a08021 10a3000f 00808821 .......!.......!\
  0x004002f0 3404ffff 12040005 8fbf0018 8fb10014 4...............\
  0x00400300 8fb00010 03e00008 27bd0020 5620fffb ........'.. V ..\
  0x00400310 8fbf0018 3c041001 0c1002d6 24842460 ....<.......$.$`\
  0x00400320 081000bf 8fbf0018 24030001 5483fff1 ........$...T...\
  0x00400330 3404ffff 3c041001 0c1002b3 24842460 4...<.......$.$`\
  0x00400340 081000bd 3404ffff 27bdffe8 3c041001 ....4...'...<...\
  0x00400350 24842c90 3c05004b 24a5b180 afbf0010 $.,.<..K$.......\
  0x00400360 0c109fb2 00000000 8fbf0010 00001021 ...............!\
  0x00400370 03e00008 27bd0018 27bdffe8 24040001 ....'...'...$...\
  0x00400380 afbf0010 0c1000b4 3405ffff 8fbf0010 ........4.......\
  0x00400390 03e00008 27bd0018 27bdffe8 00002021 ....'...'..... !\
  0x004003a0 afbf0010 0c1000b4 3405ffff 8fbf0010 ........4.......\
  0x004003b0 03e00008 27bd0018 00000000 00000000 ....'...........\
  0x004003c0 27bdffe8 3c021000 24420058 ac820000 '...<...$B.X....\
  0x004003d0 afbf0014 afb00010 8ca30000 3c02004b ............<..K\
  0x004003e0 9042c15c 00808021 8c67fff4 24840004 .B.\\...!.g..$...\
  0x004003f0 24060100 00671821 a0620000 0c11b048 $....g.!.b.....H\
  0x00400400 8ca50000 a2000103 8fbf0014 8fb00010 ................\
  0x00400410 03e00008 27bd0018 27bdffe8 3c021000 ....'...'...<...\
  0x00400420 24420058 ac820000 afbf0014 afb00010 $B.X............\
  0x00400430 8ca30000 3c02004b 9042c15c 00808021 ....<..K.B.\\...!\
  0x00400440 8c67fff4 24840004 24060100 00671821 .g..$...$....g.!\
  0x00400450 a0620000 0c11b048 8ca50000 a2000103 .b.....H........\
  0x00400460 8fbf0014 8fb00010 03e00008 27bd0018 ............'...\
  0x00400470 3c021000 24420058 27bdffe8 ac820000 <...$B.X'.......\
  0x00400480 afbf0010 0c10e490 00000000 8fbf0010 ................\
  0x00400490 03e00008 27bd0018 3c021000 24420058 ....'...<...$B.X\
  0x004004a0 27bdffe8 ac820000 afbf0010 0c10e490 '...............\
  0x004004b0 00000000 8fbf0010 03e00008 27bd0018 ............'...\
  0x004004c0 27bdffe8 3c021000 24420058 ac820000 '...<...$B.X....\
  0x004004d0 afb00010 afbf0014 0c10e490 00808021 ...............!\
  0x004004e0 0c10e438 02002021 8fbf0014 8fb00010 ...8.. !........\
  0x004004f0 03e00008 27bd0018 24820004 27bdfff0 ....'...$...'...\
  0x00400500 03e00008 27bd0010 27bdffe0 308400ff ....'...'...0...\
  0x00400510 afb00010 2c900001 afb20018 afbf001c ....,...........\
  0x00400520 afb10014 00108340 14800002 24120001 .......@....$...\
  0x00400530 24122000 3c041001 24842888 10800005 $. .<...$.(.....\
  0x00400540 24060010 3c051000 8ca52404 0c10ea6c $...<.....$....l\
  0x00400550 02003821 3c041001 24842914 10800005 ..8!<...$.).....\
  0x00400560 24060008 3c051000 8ca52400 0c10ea6c $...<.....$....l\
  0x00400570 02403821 3c041001 248429a0 10800005 .@8!<...$.).....\
  0x00400580 24060010 3c051000 8ca52408 0c10ea6c $...<.....$....l\
  0x00400590 02003821 3c021001 24422c90 1040000f ..8!<...$B,..@..\
  0x004005a0 00000000 24440008 0c10038b 24510004 ....$D......$Q..\
  0x004005b0 3c031000 24630dd4 24620014 3c051001 <...$c..$b..<...\
  0x004005c0 24a52888 3c011001 ac222c94 3c011001 $.(.<....",.<...\
  0x004005d0 ac232c90 0c11093b 02202021 3c021001 .#,....;.  !<...\
  0x004005e0 24422c00 10400011 00000000 2444000c $B,..@......$D..\
  0x004005f0 0c10038b 24510008 3c031000 246300c4 ....$Q..<...$c..\
  0x00400600 24620014 3c051001 24a52914 3c011001 $b..<...$.).<...\
  0x00400610 ac222c08 3c011001 ac232c00 0c11093b .",.<....#,....;\
  0x00400620 02202021 3c011001 ac202c04 3c021001 .  !<.... ,.<...\
  0x00400630 24422d1c 1040000e 24440008 0c10038b $B-..@..$D......\
  0x00400640 24510004 3c031000 24630dd4 24620014 $Q..<...$c..$b..\
  0x00400650 3c051001 24a529a0 3c011001 ac222d20 <...$.).<...."- \
  0x00400660 3c011001 ac232d1c 0c11093b 02202021 <....#-....;.  !\
  0x00400670 3c021001 24422da8 1040000e 24440008 <...$B-..@..$D..\
  0x00400680 0c10038b 24510004 3c031000 24630dd4 ....$Q..<...$c..\
  0x00400690 24620014 3c051001 24a529a0 3c011001 $b..<...$.).<...\
  0x004006a0 ac222dac 3c011001 ac232da8 0c11093b ."-.<....#-....;\
  0x004006b0 02202021 3c021001 24422c90 24032000 .  !<...$B,.$. .\
  0x004006c0 3c041001 24842a2c 3c011001 ac222c78 <...$.*,<....",x\
  0x004006d0 3c011001 ac232d2c 10800005 24060010 <....#-,....$...\
  0x004006e0 3c051000 8ca52404 0c10ec3d 02003821 <.....$....=..8!\
  0x004006f0 3c041001 24842ac8 10800005 02403821 <...$.*......@8!\
  0x00400700 3c051000 8ca52400 0c10ec3d 24060008 <.....$....=$...\
  0x00400710 3c041001 24842b64 10800005 02003821 <...$.+d......8!\
  0x00400720 3c051000 8ca52408 0c10ec3d 24060010 <.....$....=$...\
  0x00400730 3c021001 24422ec8 1040000f 00000000 <...$B...@......\
  0x00400740 24440008 0c10038b 24500004 3c031000 $D......$P..<...\
  0x00400750 24630da4 24620014 3c051001 24a52a2c $c..$b..<...$.*,\
  0x00400760 3c011001 ac222ecc 3c011001 ac232ec8 <...."..<....#..\
  0x00400770 0c110b78 02002021 3c021001 24422e34 ...x.. !<...$B.4\
  0x00400780 10400011 00000000 2444000c 0c10038b .@......$D......\
  0x00400790 24500008 3c021000 24420094 24430014 $P..<...$B..$C..\
  0x004007a0 3c051001 24a52ac8 3c011001 ac232e3c <...$.*.<....#.<\
  0x004007b0 3c011001 ac222e34 0c110b78 02002021 <....".4...x.. !\
  0x004007c0 3c011001 ac202e38 3c021001 24422f58 <.... .8<...$B/X\
  0x004007d0 1040000f 00000000 24440008 0c10038b .@......$D......\
  0x004007e0 24500004 3c021000 24420da4 24430014 $P..<...$B..$C..\
  0x004007f0 3c051001 24a52b64 3c011001 ac232f5c <...$.+d<....#/\\\
  0x00400800 3c011001 ac222f58 0c110b78 02002021 <...."/X...x.. !\
  0x00400810 3c021001 24422fe8 10400010 8fbf001c <...$B/..@......\
  0x00400820 24440008 0c10038b 24500004 3c021000 $D......$P..<...\
  0x00400830 24420da4 24430014 3c051001 24a52b64 $B..$C..<...$.+d\
  0x00400840 3c011001 ac232fec 3c011001 ac222fe8 <....#/.<...."/.\
  0x00400850 0c110b78 02002021 8fbf001c 8fb20018 ...x.. !........\
  0x00400860 8fb10014 8fb00010 3c021001 24422ec8 ........<...$B..\
  0x00400870 24032000 3c011001 ac222eac 3c011001 $. .<...."..<...\
  0x00400880 ac232f68 03e00008 27bd0020 08100233 .#/h....'.. ...3\
  0x00400890 00000000 08100233 00000000 08100233 .......3.......3\
  0x004008a0 00000000 00808021 3c021000 244218f8 .......!<...$B..\
  0x004008b0 3c041001 24842c98 3c011001 ac222c94 <...$.,.<....",.\
  0x004008c0 0c1003b3 00000000 02002021 0c111bab .......... !....\
  0x004008d0 00000000 08100232 00808021 00808021 .......2...!...!\
  0x004008e0 3c021000 244218f8 3c041001 24842c0c <...$B..<...$.,.\
  0x004008f0 3c011001 ac222c08 08100230 00000000 <....",....0....\
  0x00400900 08100232 00808021 00808021 3c021000 ...2...!...!<...\
  0x00400910 244218f8 3c041001 24842d24 3c011001 $B..<...$.-$<...\
  0x00400920 ac222d20 08100230 00000000 08100232 ."- ...0.......2\
  0x00400930 00808021 00808021 3c021000 244218f8 ...!...!<...$B..\
  0x00400940 3c041001 24842db0 3c011001 ac222dac <...$.-.<...."-.\
  0x00400950 08100230 00000000 08100232 00808021 ...0.......2...!\
  0x00400960 08100233 00000000 08100233 00000000 ...3.......3....\
  0x00400970 08100233 00000000 00808021 3c021000 ...3.......!<...\
  0x00400980 244218e8 3c041001 24842ed0 3c011001 $B..<...$...<...\
  0x00400990 ac222ecc 08100230 00000000 08100232 .".....0.......2\
  0x004009a0 00808021 00808021 3c021000 244218e8 ...!...!<...$B..\
  0x004009b0 3c041001 24842e40 3c011001 ac222e3c <...$..@<....".<\
  0x004009c0 08100230 00000000 08100232 00808021 ...0.......2...!\
  0x004009d0 00808021 3c021000 244218e8 3c041001 ...!<...$B..<...\
  0x004009e0 24842f60 3c011001 ac222f5c 08100230 $./`<...."/\\...0\
  0x004009f0 00000000 08100232 00808021 3c021000 .......2...!<...\
  0x00400a00 244218e8 00808021 3c011001 ac222fec $B.....!<...."/.\
  0x00400a10 3c041001 08100230 24842ff0 27bdffe8 <......0$./.'...\
  0x00400a20 3c041001 24842888 afbf0010 0c10ead9 <...$.(.........\
  0x00400a30 00000000 3c041001 0c10ead9 24842914 ....<.......$.).\
  0x00400a40 3c041001 0c10ead9 248429a0 3c041001 <.......$.).<...\
  0x00400a50 0c10ecaa 24842a2c 3c041001 0c10ecaa ....$.*,<.......\
  0x00400a60 24842ac8 3c041001 0c10ecaa 24842b64 $.*.<.......$.+d\
  0x00400a70 8fbf0010 03e00008 27bd0018 3c021000 ........'...<...\
  0x00400a80 8c420040 27bdffe8 afbf0010 10400007 .B.@'........@..\
  0x00400a90 24040001 8fbf0010 24420001 3c011000 $.......$B..<...\
  0x00400aa0 ac220040 03e00008 27bd0018 24020001 .".@....'...$...\
  0x00400ab0 3c011000 0c100142 a0220044 3c021000 <......B.".D<...\
  0x00400ac0 8c420040 081002a6 8fbf0010 3c021000 .B.@........<...\
  0x00400ad0 8c420040 27bdffe8 afbf0010 10400007 .B.@'........@..\
  0x00400ae0 24040001 8fbf0010 24420001 3c011000 $.......$B..<...\
  0x00400af0 ac220040 03e00008 27bd0018 24020001 .".@....'...$...\
  0x00400b00 3c011000 0c100142 a0220044 3c021000 <......B.".D<...\
  0x00400b10 8c420040 081002ba 8fbf0010 3c021000 .B.@........<...\
  0x00400b20 8c420040 27bdffe8 afbf0010 2442ffff .B.@'.......$B..\
  0x00400b30 3c011000 10400004 ac220040 8fbf0010 <....@...".@....\
  0x00400b40 03e00008 27bd0018 0c100287 00000000 ....'...........\
  0x00400b50 081002d0 8fbf0010 3c021000 8c420040 ........<....B.@\
  0x00400b60 27bdffe8 afbf0010 2442ffff 3c011000 '.......$B..<...\
  0x00400b70 10400004 ac220040 8fbf0010 03e00008 .@...".@........\
  0x00400b80 27bd0018 0c100287 00000000 081002df '...............\
  0x00400b90 8fbf0010 3c031000 24630048 8c640000 ....<...$c.H.d..\
  0x00400ba0 27bdfff0 24820004 24840001 ac640000 '...$...$....d..\
  0x00400bb0 03e00008 27bd0010 27bdffd8 afb10014 ....'...'.......\
  0x00400bc0 28a20008 24910020 afb40020 afb3001c (...$.. ... ....\
  0x00400bd0 afb20018 afb00010 afbf0024 00809021 ...........$...!\
  0x00400be0 00a08021 24130008 14400038 0220a021 ...!$....@.8. .!\
  0x00400bf0 3c027fff 3442ffff 00a2102a 1440000e <...4B.....*.@..\
  0x00400c00 24b30001 8c820010 24900018 34420001 $.......$...4B..\
  0x00400c10 ac820010 02001021 8fbf0024 8fb40020 .......!...$... \
  0x00400c20 8fb3001c 8fb20018 8fb10014 8fb00010 ................\
  0x00400c30 03e00008 27bd0028 0c10e480 001320c0 ....'..(...... .\
  0x00400c40 00403821 00401821 2402ffff 12020006 .@8!.@.!$.......\
  0x00400c50 02002021 2484ffff ac600000 ac600004 .. !$....`...`..\
  0x00400c60 1482fffc 24630008 8e420060 00e08821 ....$c...B.`...!\
  0x00400c70 1840000e 00003021 8e430064 000610c0 .@....0!.C.d....\
  0x00400c80 00472821 00431021 8c440000 24c60001 .G(!.C.!.D..$...\
  0x00400c90 aca40000 8c430004 aca30004 8e420060 .....C.......B.`\
  0x00400ca0 00c2102a 5440fff5 8e430064 8e440064 ...*T@...C.d.D.d\
  0x00400cb0 10800007 001010c0 50940006 ae530060 ........P....S.`\
  0x00400cc0 14800007 00000000 ae400064 001010c0 .........@.d....\
  0x00400cd0 ae530060 02228021 08100305 ae510064 .S.`.".!.....Q.d\
  0x00400ce0 0c10e430 00000000 08100333 ae400064 ...0.......3.@.d\
  0x00400cf0 0c10dfe8 00000000 8e440064 14800012 .........D.d....\
  0x00400d00 00000000 8e420010 8e43000c ae400064 .....B...C...@.d\
  0x00400d10 34420001 00431824 14600005 ae420010 4B...C.$.`...B..\
  0x00400d20 0c10e001 26500018 08100306 02001021 ....&P.........!\
  0x00400d30 3c04004b 2484b250 0c11065c 00000000 <..K$..P...\\....\
  0x00400d40 08100348 00000000 0c10e430 00000000 ...H.......0....\
  0x00400d50 08100342 8e420010 0c10e001 00808021 ...B.B.........!\
  0x00400d60 0c111bab 02002021 27bdffe0 24031002 ...... !'...$...\
  0x00400d70 afb00018 24020006 00808021 ac830008 ....$......!....\
  0x00400d80 ac820000 ac800004 ac800014 ac800060 ...............`\
  0x00400d90 26100068 afbf001c 0c101f1c 27a40010 &..h........'...\
  0x00400da0 02002021 0c1023ad 27a50010 0c10232f .. !..#.'.....#/\
  0x00400db0 27a40010 8fbf001c 8fb00018 03e00008 '...............\
  0x00400dc0 27bd0020 27bdffd8 afb00010 24b00068 '.. '.......$..h\
  0x00400dd0 afb20018 afb10014 00a09021 00c08821 ...........!...!\
  0x00400de0 02002821 afbf0020 afb3001c 0c101f40 ..(!... .......@\
  0x00400df0 00809821 02002021 0c1023ad 02202821 ...!.. !..#.. (!\
  0x00400e00 02402021 0c1003fd 24050001 02601021 .@ !....$....`.!\
  0x00400e10 8fbf0020 8fb3001c 8fb20018 8fb10014 ... ............\
  0x00400e20 8fb00010 03e00008 27bd0028 27bdffe8 ........'..('...\
  0x00400e30 00802821 ac800014 ac800018 ac80001c ..(!............\
  0x00400e40 24820020 afbf0010 24030007 2404ffff $.. ....$...$...\
  0x00400e50 2463ffff ac400000 ac400004 1464fffc $c...@...@...d..\
  0x00400e60 24420008 24a40068 0c101f1c aca00064 $B..$..h.......d\
  0x00400e70 8fbf0010 03e00008 27bd0018 27bdffe8 ........'...'...\
  0x00400e80 00802821 ac800014 ac800018 ac80001c ..(!............\
  0x00400e90 24820020 afbf0010 24030007 2404ffff $.. ....$...$...\
  0x00400ea0 2463ffff ac400000 ac400004 1464fffc $c...@...@...d..\
  0x00400eb0 24420008 24a40068 0c101f1c aca00064 $B..$..h.......d\
  0x00400ec0 8fbf0010 03e00008 27bd0018 27bdffe8 ........'...'...\
  0x00400ed0 afb00010 00002821 afbf0014 0c1003fd ......(!........\
  0x00400ee0 00808021 0c100421 02002021 8e020064 ...!...!.. !...d\
  0x00400ef0 10400006 26030020 10430004 00000000 .@..&.. .C......\
  0x00400f00 14400008 00402021 ae000064 0c10232f .@...@ !...d..#/\
  0x00400f10 26040068 8fbf0014 8fb00010 03e00008 &..h............\
  0x00400f20 27bd0018 0c10e430 00000000 081003c3 '......0........\
  0x00400f30 ae000064 27bdffe8 afb00010 00002821 ...d'.........(!\
  0x00400f40 afbf0014 0c1003fd 00808021 0c100421 ...........!...!\
  0x00400f50 02002021 8e020064 10400006 26030020 .. !...d.@..&.. \
  0x00400f60 10430004 00000000 14400008 00402021 .C.......@...@ !\
  0x00400f70 ae000064 0c10232f 26040068 8fbf0014 ...d..#/&..h....\
  0x00400f80 8fb00010 03e00008 27bd0018 0c10e430 ........'......0\
  0x00400f90 00000000 081003dd ae000064 27bdffe0 ...........d'...\
  0x00400fa0 afb20018 00809021 24040010 afbf001c .......!$.......\
  0x00400fb0 afb10014 afb00010 00c08821 0c10e44c ...........!...L\
  0x00400fc0 00a08021 8e430014 8fbf001c ac500004 ...!.C.......P..\
  0x00400fd0 ac510008 ac430000 ac40000c 8fb10014 .Q...C...@......\
  0x00400fe0 ae420014 8fb00010 8fb20018 03e00008 .B..............\
  0x00400ff0 27bd0020 27bdffe0 afb20018 afb10014 '.. '...........\
  0x00401000 afbf001c afb00010 8c900014 00808821 ...............!\
  0x00401010 12000009 00a09021 8e020004 8e060008 .......!........\
  0x00401020 02402021 0040f809 02202821 8e100000 .@ !.@... (!....\
  0x00401030 5600fffa 8e020004 8fbf001c 8fb20018 V...............\
  0x00401040 8fb10014 8fb00010 03e00008 27bd0020 ............'.. \
  0x00401050 0c10dfe8 00000000 0c10e001 00000000 ................\
  0x00401060 0810040c 8e100000 2402ffff 10a20003 ........$.......\
  0x00401070 00000000 0c111bab 00000000 0c10df9f ................\
  0x00401080 00000000 27bdffe0 afb10014 afbf0018 ....'...........\
  0x00401090 afb00010 00808821 8c840014 50800006 .......!....P...\
  0x004010a0 ae200014 8c83000c 2462ffff 10600007 . ......$b...`..\
  0x004010b0 ac82000c ae200014 8fbf0018 8fb10014 ..... ..........\
  0x004010c0 8fb00010 03e00008 27bd0020 0c10e438 ........'.. ...8\
  0x004010d0 8c900000 1200fff7 02002021 8e03000c .......... !....\
  0x004010e0 2462ffff 1060fff9 ae02000c 0810042e $b...`..........\
  0x004010f0 ae200014 27bdffe8 308400ff afb00010 . ..'...0.......\
  0x00401100 afbf0014 3c101000 92100044 14800003 ....<......D....\
  0x00401110 02001021 16000005 00000000 8fbf0014 ...!............\
  0x00401120 8fb00010 03e00008 27bd0018 3c011000 ........'...<...\
  0x00401130 0c100287 a0200044 3c041000 0c100142 ..... .D<......B\
  0x00401140 90840044 08100447 02001021 00000000 ...D...G...!....\
  0x00401150 27bdffe8 afb00010 afbf0014 8ca30000 '...............\
  0x00401160 00808021 ac830000 8c62fff4 8ca40004 ...!.....b......\
  0x00401170 00c02821 02021021 ac440000 8e030000 ..(!...!.D......\
  0x00401180 8c64fff4 0c11093b 02042021 ae000004 .d.....;.. !....\
  0x00401190 8fbf0014 8fb00010 03e00008 27bd0018 ............'...\
  0x004011a0 0c111bab 00000000 27bdffe0 afb20018 ........'.......\
  0x004011b0 2492000c afb10014 00808821 02402021 $..........!.@ !\
  0x004011c0 afb00010 afbf001c 0c10038b 00a08021 ...............!\
  0x004011d0 3c031000 246300c4 24620014 26240008 <...$c..$b..&$..\
  0x004011e0 ae220008 ae230000 0c11093b 02002821 ."...#.....;..(!\
  0x004011f0 ae200004 8fbf001c 8fb20018 8fb10014 . ..............\
  0x00401200 8fb00010 03e00008 27bd0020 3c021000 ........'.. <...\
  0x00401210 244218f8 00808021 ae220008 0c1003b3 $B.....!."......\
  0x00401220 02402021 0c111bab 02002021 8ca30000 .@ !...... !....\
  0x00401230 27bdfff0 ac830000 8c62fff4 8ca60004 '........b......\
  0x00401240 00821021 ac460000 ac800004 03e00008 ...!.F..........\
  0x00401250 27bd0010 2485000c 3c021000 244200c4 '...$...<...$B..\
  0x00401260 3c031000 246318f8 27bdffe8 ac820000 <...$c..'.......\
  0x00401270 ac830008 ac800004 afbf0010 0c1003b3 ................\
  0x00401280 00a02021 8fbf0010 03e00008 27bd0018 .. !........'...\
  0x00401290 27bdffe8 afbf0010 8c820000 8c43fff4 '............C..\
  0x004012a0 0c100495 00832021 8fbf0010 03e00008 ...... !........\
  0x004012b0 27bd0018 27bdffe8 3c021000 244200c4 '...'...<...$B..\
  0x004012c0 3c031000 246318f8 afb00010 00808021 <...$c.........!\
  0x004012d0 ae020000 ae030008 ae000004 afbf0014 ................\
  0x004012e0 0c1003b3 2484000c 0c10e438 02002021 ....$......8.. !\
  0x004012f0 8fbf0014 8fb00010 03e00008 27bd0018 ............'...\
  0x00401300 27bdffe8 afbf0010 8c820000 8c43fff4 '............C..\
  0x00401310 0c1004ad 00832021 8fbf0010 03e00008 ...... !........\
  0x00401320 27bd0018 27bdffe8 afb00010 afbf0014 '...'...........\
  0x00401330 00a0f809 00808021 02001021 8fbf0014 .......!...!....\
  0x00401340 8fb00010 03e00008 27bd0018 27bdffe8 ........'...'...\
  0x00401350 afbf0014 afb00010 8c830000 00808021 ...............!\
  0x00401360 8c64fff4 00a0f809 02042021 02001021 .d........ !...!\
  0x00401370 8fbf0014 8fb00010 03e00008 27bd0018 ............'...\
  0x00401380 27bdffe8 afbf0014 afb00010 8c830000 '...............\
  0x00401390 00808021 8c64fff4 02042021 00a0f809 ...!.d.... !....\
  0x004013a0 24840004 02001021 8fbf0014 8fb00010 $......!........\
  0x004013b0 03e00008 27bd0018 03e00008 90820000 ....'...........\
  0x004013c0 27bdffa0 afb00050 00808021 afb10054 '......P...!...T\
  0x004013d0 27a40048 00a08821 00003021 afbf0058 '..H...!..0!...X\
  0x004013e0 0c100fab 02002821 93a20048 1040002a ......(!...H.@.*\
  0x004013f0 02001021 8e040000 afa0004c 8c82fff4 ...!.......L....\
  0x00401400 02021021 8c430084 10600028 00000000 ...!.C...`.(....\
  0x00401410 8c83fff4 8e050000 2404ffff 02031821 ........$......!\
  0x00401420 8c660078 afa40034 afa4003c afa00038 .f.x...4...<...8\
  0x00401430 afa60030 8ca2fff4 8c650084 27a3004c ...0.....e..'..L\
  0x00401440 02021021 8ca70000 24420004 afa40014 ...!....$B......\
  0x00401450 afa40044 afa20018 afa3001c afb10020 ...D........... \
  0x00401460 afa60040 afa00010 8ce20008 27a40028 ...@........'..(\
  0x00401470 0040f809 2407ffff 8e020000 8c44fff4 .@..$........D..\
  0x00401480 8fa2004c 02042021 8c850014 0c110751 ...L.. !.......Q\
  0x00401490 00a22825 02001021 8fbf0058 8fb10054 ..(%...!...X...T\
  0x004014a0 8fb00050 03e00008 27bd0060 0c1103dc ...P....'..`....\
  0x004014b0 00000000 08100504 8e040000 24020001 ............$...\
  0x004014c0 14a20019 00000000 0c10dfe8 00000000 ................\
  0x004014d0 8e030000 8c64fff4 02042021 8c850014 .....d.... !....\
  0x004014e0 0c110751 34a50001 8e020000 8c43fff4 ...Q4........C..\
  0x004014f0 02031821 8c620010 30420001 14400005 ...!.b..0B...@..\
  0x00401500 00000000 0c10e001 00000000 08100526 ...............&\
  0x00401510 02001021 0c10e581 00000000 0c10e001 ...!............\
  0x00401520 00808021 02002021 0c111bab 00000000 ...!.. !........\
  0x00401530 27bdff98 afb00058 00808021 afb1005c '......X...!...\\\
  0x00401540 27a40048 00a08821 00003021 afbf0060 '..H...!..0!...`\
  0x00401550 0c100fab 02002821 93a20048 10400038 ......(!...H.@.8\
  0x00401560 02001021 8e040000 afa0004c 8c82fff4 ...!.......L....\
  0x00401570 02021021 8c430084 10600039 00000000 ...!.C...`.9....\
  0x00401580 8c83fff4 8e050000 2404ffff 02031821 ........$......!\
  0x00401590 8c660078 afa40034 afa4003c afa00038 .f.x...4...<...8\
  0x004015a0 afa60030 8ca2fff4 8c650084 27a3004c ...0.....e..'..L\
  0x004015b0 02021021 8ca70000 24420004 afa20018 ...!....$B......\
  0x004015c0 27a20050 afa40014 afa40044 afa3001c '..P.......D....\
  0x004015d0 afa20020 afa60040 afa00010 8ce2000c ... ...@........\
  0x004015e0 27a40028 0040f809 2407ffff 8fa3004c '..(.@..$......L\
  0x004015f0 30620004 14400017 00602821 8fa40050 0b...@...`(!...P\
  0x00401600 28828000 54400014 34a30004 24027fff (...T@..4...$...\
  0x00401610 0044102a 54400010 34a30004 97a20052 .D.*T@..4......R\
  0x00401620 a6220000 8e020000 8c44fff4 02042021 .".......D.... !\
  0x00401630 8c850014 0c110751 00a32825 02001021 .......Q..(%...!\
  0x00401640 8fbf0060 8fb1005c 8fb00058 03e00008 ...`...\\...X....\
  0x00401650 27bd0068 34a30004 08100589 afa3004c '..h4..........L\
  0x00401660 0c1103dc 00000000 08100560 8e040000 ...........`....\
  0x00401670 24020001 14a20019 00000000 0c10dfe8 $...............\
  0x00401680 00000000 8e030000 8c64fff4 02042021 .........d.... !\
  0x00401690 8c850014 0c110751 34a50001 8e020000 .......Q4.......\
  0x004016a0 8c43fff4 02031821 8c620010 30420001 .C.....!.b..0B..\
  0x004016b0 14400005 00000000 0c10e001 00000000 .@..............\
  0x004016c0 08100590 02001021 0c10e581 00000000 .......!........\
  0x004016d0 0c10e001 00808021 02002021 0c111bab .......!.. !....\
  0x004016e0 00000000 27bdffa0 afb00050 00808021 ....'......P...!\
  0x004016f0 afb10054 27a40048 00a08821 00003021 ...T'..H...!..0!\
  0x00401700 afbf0058 0c100fab 02002821 93a20048 ...X......(!...H\
  0x00401710 1040002a 02001021 8e040000 afa0004c .@.*...!.......L\
  0x00401720 8c82fff4 02021021 8c430084 10600028 .......!.C...`.(\
  0x00401730 00000000 8c83fff4 8e050000 2404ffff ............$...\
  0x00401740 02031821 8c660078 afa40034 afa4003c ...!.f.x...4...<\
  0x00401750 afa00038 afa60030 8ca2fff4 8c650084 ...8...0.....e..\
  0x00401760 27a3004c 02021021 8ca70000 24420004 '..L...!....$B..\
  0x00401770 afa40014 afa40044 afa20018 afa3001c .......D........\
  0x00401780 afb10020 afa60040 afa00010 8ce20010 ... ...@........\
  0x00401790 27a40028 0040f809 2407ffff 8e020000 '..(.@..$.......\
  0x004017a0 8c44fff4 8fa2004c 02042021 8c850014 .D.....L.. !....\
  0x004017b0 0c110751 00a22825 02001021 8fbf0058 ...Q..(%...!...X\
  0x004017c0 8fb10054 8fb00050 03e00008 27bd0060 ...T...P....'..`\
  0x004017d0 0c1103dc 00000000 081005cd 8e040000 ................\
  0x004017e0 24020001 14a20019 00000000 0c10dfe8 $...............\
  0x004017f0 00000000 8e030000 8c64fff4 02042021 .........d.... !\
  0x00401800 8c850014 0c110751 34a50001 8e020000 .......Q4.......\
  0x00401810 8c43fff4 02031821 8c620010 30420001 .C.....!.b..0B..\
  0x00401820 14400005 00000000 0c10e001 00000000 .@..............\
  0x00401830 081005ef 02001021 0c10e581 00000000 .......!........\
  0x00401840 0c10e001 00808021 02002021 0c111bab .......!.. !....\
  0x00401850 00000000 27bdff98 afb00058 00808021 ....'......X...!\
  0x00401860 afb1005c 27a40048 00a08821 00003021 ...\\'..H...!..0!\
  0x00401870 afbf0060 0c100fab 02002821 93a20048 ...`......(!...H\
  0x00401880 10400039 02001021 8e040000 afa0004c .@.9...!.......L\
  0x00401890 8c82fff4 02021021 8c430084 1060003a .......!.C...`.:\
  0x004018a0 00000000 8c83fff4 8e050000 2404ffff ............$...\
  0x004018b0 02031821 8c660078 afa40034 afa4003c ...!.f.x...4...<\
  0x004018c0 afa00038 afa60030 8ca2fff4 8c650084 ...8...0.....e..\
  0x004018d0 27a3004c 02021021 8ca70000 24420004 '..L...!....$B..\
  0x004018e0 afa20018 27a20050 afa40014 afa40044 ....'..P.......D\
  0x004018f0 afa3001c afa20020 afa60040 afa00010 ....... ...@....\
  0x00401900 8ce2000c 27a40028 0040f809 2407ffff ....'..(.@..$...\
  0x00401910 8fa3004c 30620004 14400018 00602821 ...L0b...@...`(!\
  0x00401920 8fa40050 3c028000 0082102a 54400014 ...P<......*T@..\
  0x00401930 34a30004 3c027fff 3442ffff 0044102a 4...<...4B...D.*\
  0x00401940 5440000f 34a30004 ae240000 8e020000 T@..4....$......\
  0x00401950 8c44fff4 02042021 8c850014 0c110751 .D.... !.......Q\
  0x00401960 00a32825 02001021 8fbf0060 8fb1005c ..(%...!...`...\\\
  0x00401970 8fb00058 03e00008 27bd0068 34a30004 ...X....'..h4...\
  0x00401980 08100653 afa3004c 0c1103dc 00000000 ...S...L........\
  0x00401990 08100629 8e040000 24020001 14a20019 ...)....$.......\
  0x004019a0 00000000 0c10dfe8 00000000 8e030000 ................\
  0x004019b0 8c64fff4 02042021 8c850014 0c110751

Everything that handles syscalls and the MIPS object (verilator related things) can be commented out as it has no effect on this issue.

I don't get a segfault even with this sample. If you do, this would point to lines 57, 58, and 59. Switch to vectors, or at least use new int[z]

Thanks for taking a look at it. I'm going to run a few data subsets and see what happens. If I still get the fault I'll switch to vector.

It would really help if you could post the entire input file, that would allow us to debug the code and quickly find the remaining issues.

Of course, it would save yourself a lot of time in the future if you just learn on how to use the debugger yourself. It will tell you exactly at which point in the code the segmentation fault occurs and allows you to check the value of all variables to give you a hint why it occurred.

Other than the debugger, you can define _GLIBCXX_DEBUG for your project. This will alert you if any out-of-bound accesses happens in a standard container. However, that requires you to consequently use vectors instead of arrays, of course.

I'm having difficulty uploading the entire data file for some reason. It is 2.9MB so I'm not sure why. Regardless, I'm getting the same segfault for the samples I supplied. I'll re-post the most up to date code now, which is giving me a segfault right now, with the second sample I supplied.

I definitely should learn to use a debugger in this context. I'm used to using HI-TECH's compiler and debugger but that's a different world. What would you suggest? I'm working from a Mac and I'm compiling my program with Verilator (a Verilog/c++ interface compiler.)

The only reason why I'm really shying away from vectors is because I'm unfamiliar with them and I'm trying to do this relatively quickly. This isn't my field of expertise obviously (yet) so I'm dragging my feet a bit. Can you refer me to any good text references that outline and give examples of c++ code? I'm working from Deitel and Deitel at the moment.

#include "VMIPS.h"
#include "VMIPS_MIPS.h"//required to explicitly access signals from submodules
#include <verilated.h> 
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <vector>
using namespace std;

void outputLine( const string );
static inline int hexCharValue(char);

char filename[50];
string array[274815];
unsigned int main_time = 0;
int i=0;
int k=0;//used for sorted array augmentation
int z = 0;//used for stream in counter
bool open = false;

int main(int argc, char **argv) 
{
        //define local variables/arrays
        int temp;//hex conversion accumulator
        int letter;
        string Hex;//dump variable for stream in
        
        //define objects
        ifstream inClientFile( "DAN_FILE.txt",ios::in );//stream in object
        Verilated::commandArgs(argc, argv);
	VMIPS *top = new VMIPS;
	top->CLK = 0;
        FILE *fp;
        //popen();
        
        //test if instruction file can be opened
        if ( !inClientFile )
        {
            cerr << "File couldn't be opened" << endl;
            exit( 1 );
        }

        //fill string array with all file values and determines length of program
        while ( inClientFile >> Hex )
        {
            //fills array[..] with strings
            outputLine( Hex );
            i++;
        }

        z = i;
        cout << "Z:" << z << endl;
        int DataMem[z];
        int InstructionMemory[z];
        string tempInstructionMemory[z];

        //cut out undesired strings from array
        int u = 0;
        for(i=0;i<z;i++)
        {
                if ((array[i].length() == 8)&&((array[i].find("fs24")!=1)&&(array[i].find("f0")!=1)))
                {
                        tempInstructionMemory[k] = array[i];
                        k++;
                }
                else
                {
                     u++;   
                }
        }

        //convert string hex to numerical decimal
        for( int j=0;j<=z-u-1;j++ )//(z-u);j++ )//(z-u);j++ )//(z-u);j++ )
        {
                for( int y=7;y>=0;y--)
                {
                        InstructionMemory[j]+=hexCharValue(tempInstructionMemory[j][y])<<(4*(7-y));
                }
                temp = 0;
                //out << "Index:" << j << " HEX:" << tempInstructionMemory[j] << " DEC:" << InstructionMemory[j]<<endl;
        }

        //MIPS I processor interface
	while (!Verilated::gotFinish()) 
	{	
		
		top->CLK=!(top->CLK);
                top->Iin = InstructionMemory[top->Iaddr];
                top->eval();
                top->Din = DataMem[top->Daddr];
                DataMem[top->Daddr] = top->Dout;
		main_time++;
                printf("PCOut:%d",top->v->__PVT__PCout);//example of inner register access
                //printf("\nIaddr:%d Iin:%d CLK:%d Time:%d",top->Iaddr,top->Iin,top->CLK,main_time);
                
                //time stamp
		if( top->CLK )
                {
                    printf("(%d)\n****************************************\n",main_time);
                }
                if(main_time>9)
		{
                    printf("\n********** Complete **********\n\n");
                    return 0;
		}
                
                
               //v     __PVT__RegisterFile__DOT__Reg[32]
                
                
                //SYSCALL (checks RegFile[2] "v0" for syscall type)
                if ( top->v->__PVT__RegisterFile__DOT__Reg[2] == 3690987584 )//exit 1
                {
                    cout << "Exit" << endl;
                    return 0;
                }
                else if ( ( top->v->__PVT__RegisterFile__DOT__Reg[2] == 3690987776 ) | ( open == true ) )//open 4
                {
                    if ( open == false )//allows access to open file protocol
                    {   
                        *filename = top->a0;//get filename from "a0" reg
                        open = true;//enable read\write
                        fp = fopen(filename,"rb");//generate file descriptor
                        //top->v->__PVT__RegisterFile__DOT__Reg[2] = fp;//write file descriptor to "v0" reg
                        if( ( fp = fopen( filename, "r")) == NULL)
                        {
                            puts("Cannot open the file");
                            top->v->__PVT__RegisterFile__DOT__Reg[2] = -1;
                        }
                    }
                    else//only accessable if a file is open
                    {
                        if ( top->v->__PVT__RegisterFile__DOT__Reg[2] ==  3690987648 )//read 2
                        {
                            int max = 0;
                            while(( ( letter = fgetc( fp ) ) != EOF) | (max != top->a2))
                            {
                                printf("%c",letter);
                                max++;
                            }
                            //top->v->__PVT__RegisterFile__DOT__Reg[2] = max;//number of characters read
                        }
                        else if ( top->v->__PVT__RegisterFile__DOT__Reg[2] ==  3690987712 )//write 3
                        {
                            //char input[1000];
                            //cout << "Enter input to stream:";
                            //fgets (input,999,stdin);
                            //fputs (input,fp);
                        }
                    }
                }
                else if ( top->v->__PVT__RegisterFile__DOT__Reg[2] == 3690987840 )//close 5
                {
                    fclose( fp );
                    open = false;
                }
                else if ( top->v->__PVT__RegisterFile__DOT__Reg[2] == 3690987904 )//time 6
                {
                    cout << "Time:" << main_time << endl;
                }
	}

        return 0;
}
//stream in helper function
void outputLine( const string Hex )
{
        array[i] = Hex;
}
//hex conversion helper function
static inline int hexCharValue(char ch)
{
    if (ch>='0' && ch<='9')return ch-'0';
    if (ch>='a' && ch<='f')return ch-'a'+10;
    return 0;
}
/*
 ***** Root Command Call *****

cd Desktop && cd verilator-3.802 && export VERILATOR_ROOT=//Users/dansnyder/Desktop/verilator-3.802 && cd test_MIPS && $VERILATOR_ROOT/bin/verilator --cc MIPS.v --exe sim_main.cpp && cd obj_dir/ && make -j -f VMIPS.mk VMIPS && cd .. && obj_dir/VMIPS && cd .. && cd .. && cd ..

*/

I'm having difficulty uploading the entire data file for some reason. It is 2.9MB so I'm not sure why. Regardless, I'm getting the same segfault for the samples I supplied. I'll re-post the most up to date code now, which is giving me a segfault right now, with the second sample I supplied.

The sample doesn't cause a crash for me. It looks pretty weird, though. I mean, the RTF markup can't possibly be part of the real document, or can it?
To upload the file, just use some file hoster like Mediafire and delete it once this has been solved.

I definitely should learn to use a debugger in this context. I'm used to using HI-TECH's compiler and debugger but that's a different world. What would you suggest? I'm working from a Mac and I'm compiling my program with Verilator (a Verilog/c++ interface compiler.)

I assume the actual compiler used is g++. So gdb is the debugger you should use. Don't forget to add debug information when compiling (-g switch).

The only reason why I'm really shying away from vectors is because I'm unfamiliar with them and I'm trying to do this relatively quickly. This isn't my field of expertise obviously (yet) so I'm dragging my feet a bit. Can you refer me to any good text references that outline and give examples of c++ code? I'm working from Deitel and Deitel at the moment.

All you need to know about the standard library is on the reference on this site:
http://www.cplusplus.com/reference/stl/vector/

Still, a good C++ book should explain vectors shortly after the beginning.

I fixed up the code a bit. It's still not perfect... normally you would use iterators in the loops and a proper check whether a word is actually a valid hex string would be in order as well (edit: now taken care of).
Still, I'm pretty sure that the code cannot cause any segmentation faults anymore. I left the Verilated related code commented out and didn't touch it. If you still get segfaults, the problem is in there.

Some problems I saw when I went through the code:

1. You used InstructionMemory's elements, even though they were uninitialized. Elements of int vectors will be initialized to 0, but that does not apply to arrays.
2. You used various global variables without any reason. They didn't have any helpful names either. This severely limits readability. Variables should be defined as locally as possible for the same reason.
3. You used "z", a non-constant for your array sizes. This is not legal C++, even though it works with gcc.
4. You filtered out words with f0 at position 1, thus filtering some valid hex strings.

Edit: 5. ...and you included some stray strings on the right side of the file. Since there were a few spaces, some words there happened to have the length 8.
I now included a proper check and eliminated the now somewhat obsolete tempInstructionMemory.
Still, in theory valid hex strings could appear on the right side.

//#include "VMIPS.h"
//#include "VMIPS_MIPS.h"//required to explicitly access signals from submodules
//#include <verilated.h>

#include <cstdio>
#include <cmath>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <vector>
#include <cassert>
using namespace std;

static inline int hexCharValue(char ch)
{
    if (ch>='0' && ch<='9')return ch-'0';
    if (ch>='a' && ch<='f')return ch-'a'+10;
    assert(false); //should never get here
}

static inline bool isHexChar(char ch)
{
  return (ch>='0' && ch<='9') || (ch>='a' && ch<='f');
}

static bool isValidHexString(const string& str)
{
  if (str.length()!=8)return false;
  for (uint i=0;i<str.length();i++)if (!isHexChar(str[i]))return false;
  return true;
}

int main(int argc, char **argv)
{
    ifstream inClientFile( "DAN_FILE.txt",ios::in ); //stream object

    //Verilated::commandArgs(argc, argv);
    //VMIPS *top = new VMIPS;
    //top->CLK = 0;

    //test if instruction file can be opened
    if ( !inClientFile )
    {
      cerr << "File couldn't be opened" << endl;
      return 1; //no point using exit inside main
    }

    vector<string> words;
    words.reserve(175110);
    string word;
    while (inClientFile >> word)
    { //helper function is unnecessary, can check for validity right now
      if (isValidHexString(word))words.push_back(word);
    }

    cout << "Number of valid words: " << words.size() << endl;

    vector<int> InstructionMemory;
    //convert string hex to numerical decimal
    InstructionMemory.resize(words.size());
    for( int j=0; j<words.size(); j++ )
    {
        for( int y=0; y<8; y++)
        {
            InstructionMemory[j]+=hexCharValue(words[j][y])<<(4*(7-y));
        }
    }

    //you'll have to add DataMem here - I have no idea what it is for

    //MIPS I processor interface
    /*while (!Verilated::gotFinish())
    {

    	top->CLK=!(top->CLK);
                top->Iin = InstructionMemory[top->Iaddr];
                top->eval();
                top->Din = DataMem[top->Daddr];
                DataMem[top->Daddr] = top->Dout;
    	main_time++;
                printf("PCOut:%d",top->v->__PVT__PCout);//example of inner register access
                //printf("\nIaddr:%d Iin:%d CLK:%d Time:%d",top->Iaddr,top->Iin,top->CLK,main_time);

                //time stamp
    	if( top->CLK )
                {
                    printf("(%d)\n****************************************\n",main_time);
                }
                if(main_time>9)
    	{
                    printf("\n********** Complete **********\n\n");
                    return 0;
    	}

                //SYSCAL
                if ( top->Iin == 3690987584 )//exit 1
                {
                    cout << "Exit" << endl;
                    return 0;
                }
                else if ( ( top->Iin == 3690987776 ) | ( open == true ) )//open 4
                {
                    if ( open == false )
                    {
                        cout << "Enter file name: ";
                        cin >> filename;
                        cout << endl;
                        open = true;
                        fp = fopen(filename,"rb");
                        if( ( fp = fopen( "my.txt", "r")) == NULL)
                            puts("Cannot oepn the file");
                    }
                    else
                    {
                        if ( top->Iin ==  3690987648 )//read 2
                        {
                            while( ( letter = fgetc( fp ) ) != EOF)
                                printf("%c",letter);
                        }
                        else if ( top->Iin ==  3690987712 )//write 3
                        {
                            char input[1000];
                            cout << "Enter input to stream:";
                            fgets (input,999,stdin);
                            fputs (input,fp);
                        }
                    }
                }
                else if ( top->Iin == 3690987840 )//close 5
                {
                    fclose( fp );
                    open = false;
                }
                else if ( top->Iin == 3690987904 )//time 6
                {
                    cout << "Time:" << main_time << endl;
                }
    }*/
}

The seg fault is definitely gone. Thanks for sifting through my code and fixing it. I'm going to go through what you have changed in detail, I need to alter my code methodology significantly so I can get to this point when designing a new test-bench. DataMem is going to be implemented in the same exact way. InstructionMem is just a hypothetical storage element to supply my processor with instructions via PC addressing. The DataMem is the actual memory element (data cache) for the processor. Because I can disassemble the binary into these two segments I'll just dump instructions into one file, data into another and load them serially into my instruction and data vectors.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.