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

📄 pseudoins.h

📁 模拟了tec2000的所有功能
💻 H
字号:
#include<string.h>
class Pseudoins{          //标号类,记录标号的实际地址
	friend class PseudoinsTable;
	char * ch;            //标号名称
	int value;            //地址或位移量  (int)address/offset
	Pseudoins * next;
public:
	Pseudoins(char * c,int v){   //构造函数
		value=v;
        ch=new char[strlen(c)+3];
		strcpy(ch,c);
		next=NULL;
	}
    Pseudoins * Getnext(void){return next;}
	int Getvalue(void){return value;}
	char * Getname(void){return ch;}
	int CmpPseudoins(char * cname){
		if(strcmp(ch,cname)==0) return 1;
		return -1;
	}
};
class PseudoinsTable{      //标号节点链表类,记录出现过的标号内容
Pseudoins * head;          //头节点
public:
	PseudoinsTable(){head=NULL;}
	Pseudoins * Gethead(void){return head;}
	int AddPseudoins(char *, int);
	int SearchPseudoins(char *);
};
int PseudoinsTable::AddPseudoins(char * chr,int vv){  //将标号加入PseudoinsTable中
    Pseudoins * temp, * ppp=head;
	if(head==NULL){ head=new Pseudoins(chr,vv);return 1;}
	else{
	
		temp=new Pseudoins(chr,vv);
		temp->next=head;
		head=temp;
		return 1;
	}
}
int PseudoinsTable::SearchPseudoins(char * cname){     //寻找对应标号   
    Pseudoins * temp=head;
	while(temp!=NULL){
		if(temp->CmpPseudoins(cname)==1) {
			return temp->Getvalue();        //找到返回其对应的地址值 
		}
		temp=temp->next;
	}
	return -1000;                           //没找到返回-1000
}






⌨️ 快捷键说明

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