Пример #1
0
void testIntrinsics()
{
	printf("Testing run-time intrinsics.\n\n");
	printf("Press any key to start assembling.\n\n");
	_getch();

	SoftWire::Assembler x86(false);

	static char string[] = "All working!";

	x86.push((unsigned int)string);
	x86.call((unsigned int )printf);
	x86.add(x86.esp, 4);
	x86.ret();

	void (*emulator)() = (void(*)())x86.callable();

	printf("%s\n\n", x86.getListing());
	printf("Execute code (y/n)?\n\n");

	int c;
	do
	{
		c = _getch();
	}
	while(c != 'y' && c != 'n');

	if(c == 'y')
	{
		printf("output: ");
		emulator();
		printf("\n\n");
	}
}
void x139(uint8_t* x113,int x114) { //top3
x94();
x100();
uint8_t* x115 = x113;
int x116 = x114;
x58(x115,x116);
x86();
x136();
};
Пример #3
0
int main()
{

#ifdef	CONFIG_TEST
	test();
#endif

#ifdef CONFIG_ARM
	arm();
#endif

#ifdef CONFIG_X86
	x86();
#endif

	printf("hello %s\n", __func__);

	return 0;
}
Пример #4
0
bool GPT::compile(const list<string>& ifnames, bool genBinary){  
  bool success = false;
  stringstream s;

  if(!prologue(ifnames)) {
    return false;
  }

  string ofname = _outputfile;
  if(!_useOutputFile) {
    if(!genBinary) {
      ofname += ".asm";
    } 
    #ifdef WIN32
    else
    {      
      ofname += ".exe";      
    }
    #endif
  }

  try{
    X86Walker x86(_stable);
    string asmsrc = x86.algoritmo(_astree);

    string ftmpname = createTmpFile();
    ofstream fo;

    if(!genBinary) { //salva assembly code
      fo.open(ofname.c_str(), ios_base::out);
      if(!fo) {
        s << PACKAGE << ": não foi possível abrir o arquivo: \"" << ofname << "\"" << endl;
        GPTDisplay::self()->showError(s);
        goto bail;
      }
      fo << asmsrc;
      fo.close();
    } else { //compile
      fo.open(ftmpname.c_str(), ios_base::out);
      if(!fo) {
        s << PACKAGE << ": erro ao processar arquivo temporário" << endl;
        GPTDisplay::self()->showError(s);
        goto bail;
      }
      fo << asmsrc;
      fo.close();

      stringstream cmd;
      cmd << "nasm -O1 -fbin -o \"" << ofname << "\" " << ftmpname;

      if(system(cmd.str().c_str()) == -1) {
        s << PACKAGE << ": não foi possível invocar o nasm." << endl;
        GPTDisplay::self()->showError(s);
        goto bail;
      }

      #ifndef WIN32
        cmd.str("");
        cmd << "chmod +x " << ofname;
        system(cmd.str().c_str());
      #endif
    }
  
    success = true;

    bail:
      if(ftmpname.length()>0) {
         unlink(ftmpname.c_str());
      }
    return success;
  } catch(SymbolTableException& e) {
      s << PACKAGE << ": erro interno: " << e.getMessage() << endl;
      GPTDisplay::self()->showError(s);
  }
}