stdafx.h
--------
#if !defined(AFX_STDAFX_H__)
#define AFX_STDAFX_H__)
#include <stdio.h>
#endif
stdafx.cpp
----------
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
tek05.cpp
---------
// tek05.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int main(int argc, char* argv[])
{
printf("Hello World!\n");
return 0;
}
Now , add new header file named : optable.h
optable.h
---------
#if !defined(__OPTABLE__)
#define __OPTABLE__
struct op_table{
string Name;
string OpCode;
string Rs;
string Rt;
string Rd;
string Shamt;
string Funct;
op_table(){};
static void FillOpTable(op_table arr[], int dim)
{
int i=0;
// add code to control the index
arr[0].Name = "add";
arr[0].OpCode = "000000";
arr[0].Funct = "100000";
arr[0].Shamt = "00000";
arr[1].Name = "sub";
arr[1].OpCode = "000000";
arr[1].Shamt = "00000";
arr[1].Funct = "100010";
///
};
};
#endif
Modify stdafx.h as follows:
stdafx.h
--------
#if !defined(AFX_STDAFX_H__)
#define AFX_STDAFX_H__)
#include <stdio.h>
#include <iostream>
using std::string;
#include "optable.h"
#ndif
Modify the tek05.cpp as follows:
tek05.cpp
---------
// tek05.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int main(int argc, char* argv[])
{
op_table OPTAB[31];
op_table::FillOpTable(OPTAB, sizeof(OPTAB)/sizeof(op_table));
return 0;
}