⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loader.h

📁 run mips program using C++
💻 H
字号:
#ifndef _PROGRAM_H_#define _PROGRAM_H_#include "structures.h"// the assembly language program class, you are not suggested to modify itclass Program{public:	unsigned int GetOPCode(const char *op);				// get the operator code by its name	unsigned int GetFunct(const char *op);				// get the funct code of the operator	unsigned int GetRegCode(const char *reg);			// get the register code by its name	char*		 GetRegName(const unsigned int reg);	// get the register name by its code	int			 LoadProgram(const char *file);			// load a program from the file to the CodeLine member														// return the number of instructions in the program	unsigned int LoadInstr(const unsigned int PC);		// load one instruction from CodeLine program[]														// return the 32-bit code of the instruction	Program();	~Program();private:	void		 FixLabels(char *line);					// used for double checking the instructions with labels	unsigned int GenerateInstr(char *line);				// translate an instruction into an 32-bit code and store														// all the information in an item of CodeLine program[]	int instrPos;public:	Reg		 RegSet[REGISTER_NUM];						// the set of all 32 registers	Operator OPSet[INSTR_TYPE];							// the set of operators involved	CodeLine program[MAX_INSTR_NUM];					// store the information of the program including														//	1. the characters,		e.g. add $s0, $s0, $t1														//  2. the 32-bit code,		e.g. 0x02098020														//  3. the Instr structure, e.g. OP = 0,   RS = 0x10														//								 RT = 0x9, RD = 0x10														//								 SH = 0,   FN = 0x20														//								 IM = 0x-1,AD = 0x-1private:	unsigned int instrNum;				// number of instructions in the program	unsigned int labelNum;				// number of labels in the program, also the bound of the labelTable	unsigned int flag;	Label labelTable[MAX_LABEL_NUM];	// the label table storing all labels in the program};#endif // _PROGRAM_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -