|
一个简单的C语言编译器(27) 0,0,0,0,0,0,0,47,20,//state35 0,0,0,0,0,0,0,0,48,//state36 0,0,0,0,0,0,0,0,0,//state37 0,0,0,0,0,50,41,19,20,//state38 0,0,0,0,0,0,51,19,20,//state39 0,0,0,0,0,0,0,0,0,//state40 0,0,0,0,0,0,0,0,0,//state41 0,0,0,0,0,0,0,0,0,//state42 0,0,0,0,0,0,0,0,0,//state43 0,0,0,0,0,0,0,0,0,//state44 0,0,0,0,0,0,0,0,0,//state45 0,0,0,0,0,0,0,0,0,//state46 0,0,0,0,0,0,0,0,0,//state47 0,0,0,0,0,0,0,0,0,//state48 0,0,0,0,0,0,0,0,0,//state49 0,0,0,0,0,0,0,0,0,//state50 0,0,0,0,0,0,0,0,0,//state51 0,0,0,0,0,0,0,0,0,//state52 0,54,0,0,0,0,0,0,0,//state53 0,0,0,0,0,0,0,0,0//state54 }; Compiler::optimize() { int i,j,f; string t="\tpush ax\n\tpop ax\n"; do{ f=0; j=code.length()-17; for(i=0;i<j;i++){ if(code.substr(i,17)==t){ f=1; code.replace(i,17,""); break; } } }while(f); } int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { string file(lpCmdLine); file=file.substr(0,file.find_last_of('.')); if(!file.empty()){ Compiler cc(file); cc.preProcess(); cc.parser(); cc.emitter(); ofstream bat; bat.open((file+".bat").c_str(),ios::out); bat<<"masm "<<file<<".asm"<<endl;
|