?? code.h
字號:
#define pc 7
#define mp 6
#define gp 5
#define ac 0
#define ac1 1
class Code
{
private:
char *codefilename;
static int emitLoc;
static int highEmitLoc;
ofstream fcout;
public:
Code(char *);
void emitComment( char * c );
void emitRO( char *op, int r, int s, int t, char *c);
void emitRM( char * op, int r, int d, int s, char *c);
int emitSkip( int howMany);
void emitBackup( int loc);
void emitRestore(void);
void emitRM_Abs( char *op, int r, int a, char * c);
};
int Code::emitLoc = 0;
int Code::highEmitLoc = 0;
Code::Code(char* codefile)
{
codefilename = new char [strlen(codefile)+1];
strcpy(codefilename,codefile);
fcout.open(codefile);
}
void Code::emitComment( char * c )
{
cout<<"*\t"<<c<<endl;
}
void Code::emitRO( char *op, int r, int s, int t, char *c)
{
fcout<<setw(3)<<emitLoc<<':'<<setw(7)<<op<<setw(3)<<r<<','<<s<<','<<t<<endl;
cout<<setw(3)<<emitLoc++<<setw(5)<<op<<r<<','<<s<<t<<'\t'<<c<<endl;
if (highEmitLoc < emitLoc) highEmitLoc = emitLoc ;
}
void Code::emitRM( char * op, int r, int d, int s, char *c)
{
fcout<<setw(3)<<emitLoc<<':'<<setw(7)<<op<<setw(3)<<r<<','<<d<<'('<<s<<')'<<endl;
cout<<setw(3)<<emitLoc++<<setw(5)<<op<<r<<','<<d<<'('<<s<<')'<<'\t'<<c<<endl;
if (highEmitLoc < emitLoc) highEmitLoc = emitLoc ;
}
int Code::emitSkip( int howMany)
{
int i = emitLoc;
emitLoc += howMany ;
if (highEmitLoc < emitLoc) highEmitLoc = emitLoc ;
return i;
}
void Code::emitBackup( int loc)
{
if (loc > highEmitLoc) emitComment("BUG in emitBackup");
emitLoc = loc ;
}
void Code::emitRestore(void)
{
emitLoc = highEmitLoc;
}
void Code::emitRM_Abs( char *op, int r, int a, char * c)
{
fcout<<setw(3)<<emitLoc<<':'<<setw(7)<<op<<setw(3)<<r<<','<<a-(emitLoc+1)<<'('<<pc<<')'<<endl;
cout<<setw(3)<<emitLoc<<setw(5)<<op<<r<<','<<a-(emitLoc+1)<<'('<<pc<<')'<<'\t'<<c<<endl;
emitLoc++;
if (highEmitLoc < emitLoc) highEmitLoc = emitLoc ;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -