void AddGlobalName(struct idrec *ptr) { if(ptr!=NULL){ AddGlobalName(ptr->right); if((ptr->rectok==tk_proc&&ptr->recsegm>=NOT_DYNAMIC)|| (ptr->rectok>=tk_bits&&ptr->rectok<=tk_doublevar)|| (ptr->rectok==tk_structvar)){ AddNameToPul(ptr->recid); numsymbols++; if(ptr->rectok==tk_proc){ outword(0x1c); //size outdword(0x20); //type } else{ outword(0x18); outdword(0x21); } outword(0); outdword(0); outdword(numsymbols); //name outdword(0); if(ptr->recpost==0){ outdword(ptr->recnumber); //offset outword(segcode); //segm } else{ outdword(ptr->recnumber+(wbss!=FALSE?0:ooutptr)); outword(1); } if(ptr->rectok==tk_proc)outdword(0); } AddGlobalName(ptr->left); } }
void x86Machine::shutdown(Progress &pg) { ShutdownInfo info; if(shutdownSupported(&info)) { pg.itemStarting("Shutting down."); // send the shutdown command outword(info.PM1a_CNT,info.SLP_TYPa | info.SLP_EN); if(info.PM1b_CNT != 0) outword(info.PM1b_CNT,info.SLP_TYPb | info.SLP_EN); } else pg.itemStarting("You can turn off now."); }
HTMLGenerator::HTMLGenerator(WordTree* inwords, string inout) { outdir = inout; if(outdir.find("/") == -1) outdir.append("/"); words = inwords; ofstream outindex((outdir + "index.html").c_str()); outindex << "<html><head><title>" << endl << "Ged Crimsonclaw's page of Letters" << endl << "</title></head><body>" << endl << "Here Ged has compiled, for your enjoyment " << "a list of the first letters of all the " << "words you may wish to discover. <br>" << endl << "Please enjoy browsing the various links " << "found on these pages. <br><br>" << endl; Word* temp = words->pop(); for(char i = 'a'; i <= 'z'; i++) { outindex << "<a href=" << i << ".html>" << (char)toupper(i) << "</a><br>" << endl; ofstream outword((outdir + i + ".html").c_str()); outword << "<html><head><title>" << endl << "Ged Crimsonclaw's " << (char)toupper(i) << " page" << endl << "</title></head><body>" << endl << "Here Ged has compiled, for your enjoyment " << "a list of all the words starting with the " << "letter " << (char)toupper(i) << ".<br>" << endl << "Please enjoy browsing the various " << endl << "links found on these pages.<br><br>" <<endl; while(temp != 0 && temp->word[0] == i) { addWord(temp, outword); delete temp; temp = words->pop(); }//while outword << "</body></html>" << endl; }//for outindex << "</body></html>" << endl; }
PUBLIC void genimage() { WORD pc = 0; int i; register Code *c; register WORD tag; asm_Module *m; VMRef curblock; curmod = module0; m = VMAddr(asm_Module,curmod); curblock = m->start; VMlock(curblock); code = VMAddr(Code,curblock); VMDirty(curblock); imageheader(simPc+4); /* +4 for trailing 0 */ codepos = 0; for(;;) { tag = (c = code)->type; oldloc = c->loc; if( tag == s_newseg ) { VMunlock(curblock); curblock = c->value.v; VMlock(curblock); code = VMAddr(Code,curblock); VMDirty(curblock); continue; } if ( tag == s_end ) { VMunlock(curblock); m = VMAddr(asm_Module,curmod); curmod = m->next; if( NullRef(curmod) ) break; m = VMAddr(asm_Module,curmod); curblock = m->start; VMlock(curblock); code = VMAddr(Code,curblock); VMDirty(curblock); continue; } if( pc != code->loc ) error("Phase error in Genimage"); if( 0 <= tag && tag <= 15 ) /* a direct operation */ { WORD pf; WORD val = eval((WORD)code->vtype,code->value.w,(WORD)pc+code->size); trace("%8x: Fn %2x %2x %8x",pc,tag,etype,val); /* El Grando Kludgerama - under certain pathalogical curcumstances we have to generate a value in more bytes than strictly necessary to get the code offsets to work. The following line sorts this out for us. */ pf=pfsize(val); if( pf < c->size ) { if(traceflags&db_kludge) _trace("%8x: Kludge fix %d -> %d type %d value %d vtype %d",pc, pfsize(val),(WORD)code->size,tag,val,(WORD)code->vtype); waste += c->size-pf; while( pf++ < code->size ) outbyte1(f_pfix); } else if( pf > code->size ) { _trace("pf %d c->size %d; code %x val %x",pf,c->size,tag,val); error("Code size error"); } encode( (WORD)(tag<<4), val, outbyte1); goto next; } switch( (int)tag ) { case s_newfile: strcpy(infile,(char *)code->value.w); break; case s_bss: trace("%8x: BSS %d",pc,(WORD)code->size); for( i = 0; i < code->size ; i++ ) outbyte(0); break; case s_literal: trace("%8x: CODE %d",pc,(WORD)code->size); for( i = 0; i < code->size ; i++ ) outbyte(((UBYTE *)(&code->value.w))[i]); break; case s_code: { UBYTE *v = VMAddr(UBYTE,code->value.v); trace("%8x: CODE %d",pc,(WORD)code->size); for( i = 0; i < code->size ; i++ ) outbyte(v[i]); break; } case s_init: trace("%8x: INIT",pc); if( NullRef(code->value.v) ) outword(0L); else { WORD next = VMAddr(Code,code->value.v)->loc; outword((WORD)(next-pc)); } break; case s_word: { WORD val = eval((WORD)code->vtype,code->value.w,(WORD)pc); trace("%8x: WORD %2x %8x",pc,etype,val); if( asize(pc) != 0 ) warn("WORD not on word boundary"); /* default to val */ outword(val); break; } case s_align: trace("%8x: ALIGN %d",pc,(WORD)code->size); waste += code->size; for( i = 0 ; i < code->size ; i++ ) outbyte1(f_pfix); break; case s_module: case s_global: case s_data: case s_common: case s_size: case s_ref: break; } next: pc += code->size; code++; } outword(0L); /* image trailer, replaces end.p */ }
int CreateW32Debug() { int sstNames,sstDirectory; int startcode=outptr; int sstGlobalSym; int sstsrc; unsigned int i,j,jj,ofs; for(;numsymbols<(short)totalmodule;numsymbols++)AddNameToPul((startfileinfo+numsymbols)->filename); segcode=(wbss==FALSE?1:2); outptr=0; outdword(0x41304246); // TDS - signature outdword(0); // offset of Subsection Directory (fill later) //sstModule subsection outdword(0); // OvlNum=0 & LibIndex=0 outword(segcode); // SegCount outword(0x5643); // CV-style outdword(1); // Name for(i=0;i<4;i++)outdword(0); // outdword(0); //Time // outdword(0); // outdword(0); // outdword(0); if(wbss){ outword(0x0001); // SegNumber outword(0); // flag outdword(0); // start outdword(postsize); // len } outword(segcode); // SegNumber outword(0x0001); // flag outdword(startptr); // start outdword(startcode); // len sstsrc=outptr; //sstSrcModule subsection outword((short)numcorrel); //cFile - количество SRC-файлов(сегментов) outword((short)numcorrel); // SegCount (see SegCount in sstModule ofs=14*numcorrel+4; for(i=0,jj=0;i<(unsigned int)numcorrel;i++){ if(i!=0)jj=jj+((corinfo+i-1)->count+1)*6+22; outdword(ofs+jj); } for(i=0;i<(unsigned int)numcorrel;i++){ outdword((corinfo+i)->ofs); outdword((corinfo+i)->end); } for(i=0;i<(unsigned int)numcorrel;i++)outword(segcode); // массив индексов сегментов for(i=0;i<(unsigned int)numcorrel;i++){ outword(1); // Segm# outdword((corinfo+i)->file+1);// File# outdword(outptr-sstsrc+12); outdword((corinfo+i)->ofs); outdword((corinfo+i)->end); outword(segcode); //Segm# jj=(corinfo+i)->count; outword(jj+1); // Lines count ofs=(corinfo+i)->startline; for(j=0;j<jj;j++)outdword(dbgloc[j+ofs]); outdword((corinfo+i)->end); for(j=0;j<jj;j++)outword(dbgnum[j+ofs]); outword(0); } //таблица глобальных символов sstGlobalSym=outptr; for(i=0;i<8;i++)outdword(0); // outdword(0); //modindex // outdword(0); //size correct later // outdword(0); // outdword(0); // outdword(0); // outdword(0); //num others correct later // outdword(0); //total correct later // outdword(0); //SymHash, AddrHash outdword(0x02100008); //S_ENTRY32 outdword(EntryPoint()); outword(segcode); AddGlobalName(treestart); sstNames=outptr; outdword(numsymbols); outptr=sstGlobalSym+4; outdword(sstNames-sstGlobalSym-32); outptr+=12; outdword(numsymbols-totalmodule); outdword(numsymbols-totalmodule); outptr=4; sstDirectory=sstNames+4+lastofspul; outdword(sstDirectory); if(fwrite(output,sstNames+4,1,hout)!=1)return -1; if(fwrite(bufname,lastofspul,1,hout)!=1)return -1; free(bufname); // Subsection Directory outptr=0; outdword(0x0C0010); outdword(4); // cDir - number of subsections outdword(0); outdword(0); //sstModule outdword(0x10120); outdword(8); //start outdword(sstsrc-8); // size // sstSrcModule outdword(0x10127); outdword(sstsrc); //start outdword(sstNames-sstsrc);//size //sstGlobalSym outdword(0x129); outdword(sstGlobalSym); //start outdword(sstNames-sstGlobalSym); //size // sstNames outdword(0x130); outdword(sstNames); outdword(sstDirectory-sstGlobalSym); outdword(0x41304246); // TDS - signature outdword(sstDirectory+outptr+4); // TDS-len return 0; }