当前位置: 首页>>代码示例>>C++>>正文


C++ Assembler类代码示例

本文整理汇总了C++中Assembler的典型用法代码示例。如果您正苦于以下问题:C++ Assembler类的具体用法?C++ Assembler怎么用?C++ Assembler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Assembler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: assembler

ForwardJumpBase<MaxJumpSize>::ForwardJumpBase(Assembler& assembler, ConditionCode condition)
    : assembler(assembler), condition(condition), jmp_inst(assembler.curInstPointer()) {
    assembler.jmp_cond(JumpDestination::fromStart(assembler.bytesWritten() + MaxJumpSize), condition);
    jmp_end = assembler.curInstPointer();
}
开发者ID:c-rhodes,项目名称:pyston,代码行数:5,代码来源:assembler.cpp

示例2: Assembler

  void CountCodePattern::initComparing() {
    // general count stub; 8 instructions.
    // 0: lis     Temp1, high(count_addr)
    // 1: lwz     Temp2, [low(count_addr) + Temp1]
    // 2: addi    Temp2, Temp2, 1
    // 3: stw     Temp2, [low(count_addr) + Temp1]
    // 4: cmpwi   Temp2, limit
    // 5: beq     10
    // 6: lis     Temp1, high(jump_addr)
    // 7: ori     Temp1, Temp1, low(jump_addr)
    // 8: mtctr   Temp1
    // 9: balwctr
    //10: mflr    RecompileTempReg
    //11: stw     RecompileTempReg, SP + saved_pc_offset * 4
    //12: bl      13
    //13: mflr    RecompileLinkReg
    //14: mtlr    RecompileTempReg
    //15: lis     R0, high(recompile_addr)
    //16: ori     R0, R0, low(recompile_addr)
    //17: mtctr   R0
    //18: balwctrl

    instsSize            = 19 * 4;
    
    countAddr_offset = 0;
          lwz_offset = 1;
          stw_offset = 3;
            limit_offset = 4;
           nm_lis_offset = 6;
           nm_ori_offset = 7;
    recompile_lis_offset = 15;
    recompile_ori_offset = 16;

    Assembler* oldAssembler = theAssembler;
    Assembler* a = theAssembler = new Assembler(instsSize, instsSize, false, true);
    { // make a new block so that the Label's destructor gets called before we reset theAssembler in Assembler::finalize
      a->load_from_address(Temp2, 0, VMAddressOperand, Temp1);      // 2 instructions
      a->addi(Temp2, Temp2, 1, NumberOperand); 
      a->stw(Temp2, 0, VMAddressOperand, Temp1);
      a->cmpwi( Temp2, 0, NumberOperand ); // assuming limit fits in si (assert in countStub_ppc)
      Label recompile(a->printing);
      a->beq(recompile, predict_usual);   // not likley to recompile, so expect to fall through
      a->long_branch_to((pc_t)0, CodeAddressOperand, Temp1, false); // 4 instructions
      recompile.define();

      // save link so can use link to get address of this code
      // also key to profiler -- dmu 2/04
      a->mflr(RecompileTempReg);
      a->stw(RecompileTempReg, saved_pc_offset * oopSize, NumberOperand, SP);
      Label next;
      a->bl(next, NumberOperand); // needed to get addr of this code
      next.define();
      a->mflr(RecompileLinkReg);
      a->mtlr(RecompileTempReg);

      // call recompiler
      char* fnaddr = Memory->code->trapdoors->Recompile_stub_td(R0);
      a->long_branch_to(fnaddr, CodeAddressOperand, R0, false);
    }
    pattern = (pc_t)AllocateHeap(instsSize, "countStub pattern");
    copy_words((int32*)a->instsStart, (int32*)pattern, instsSize / 4);
    a->finalize();
    theAssembler = oldAssembler;
  }
开发者ID:AaronNGray,项目名称:self,代码行数:64,代码来源:countPattern_ppc.cpp

示例3: gen

 void AbstractArrayAtNode::gen() {
   BasicNode::gen();
   Label* argFail = NULL;          // if arg isn't a smi
   Label* indexFail = NULL;        // if arg is out of bounds
   Assembler* a = theAssembler;
   Location arr = genHelper->moveToReg(_src, Temp2);
   Location index = genHelper->moveToReg(arg, Temp1);
   Location size = Temp3;
   // load array size now (avoids load interlock for range check)
   a->LoadI(arr, sizeOffset, size);  
   if (!intArg) {
     // CP may have propagated a constant into arg
     intArg = arg->isConstPReg() && ((ConstPReg*)arg)->constant->is_smi();
   }
   if (!intArg) {
     // test arg for smiOop
     if (SICCountTypeTests) {
       a->startTypeTest(1, false, true);
       a->doOneTypeTest();
     }
     if (SICCountIntTagTests) a->markTagTest(1);
     a->AndCCI(index, Tag_Mask, G0);
     argFail = argFail->unify(a->BneForward(false));
     if (SICCountTypeTests) a->endTypeTest();
   }
   argFail = argFail->unify(testArg2());
   a->SubCCR(index, size, G0);
   indexFail = a->BgeuForward(false);
   Location res = isRegister(_dest->loc) ? _dest->loc : Temp1;
   bool needDestStore = genAccess(arr, index, res);
   if (needDestStore && !isRegister(_dest->loc)) {
     genHelper->moveRegToLoc(res, _dest->loc);
   }
   Label* done = a->BraForward(true);
   MergeNode* failMerge = (MergeNode*)next1();
   if (argFail) {
     argFail->define();
     if (error) {
       Location err = isRegister(error->loc) ? error->loc : Temp1;
       genHelper->loadImmediateOop(VMString[BADTYPEERROR], err);
       if (err != error->loc) genHelper->moveRegToLoc(err, error->loc);
     }
     if (failMerge) // test added by dmu 4/27/96
       failMerge->l = failMerge->l->unify(a->BraForward(true));
   }
   indexFail->define();
   if (error) {
     Location err = isRegister(error->loc) ? error->loc : Temp1;
     genHelper->loadImmediateOop(VMString[BADINDEXERROR], err);
     if (err != error->loc) genHelper->moveRegToLoc(err, error->loc);
   }
   if (failMerge) // test added by dmu 4/27/96
     failMerge->l = failMerge->l->unify(a->BraForward(true));
   done->define();
 }
开发者ID:ardeujho,项目名称:self,代码行数:55,代码来源:node_sparc.cpp

示例4: Assembler

  void CountCodePattern::initComparing() {
    // general count stub;
    //  0: lea   count_addr, %eax
    //  6: movl  (%eax), %edx
    //  8: leal  1(%edx), %edx
    // 11: movl  %edx, (%eax)
    // 13: cmpl  %edx, limit
    // ??: jne jump_addr
    //     call recompile_addr
 
    
    Assembler* oldAssembler = theAssembler;
    Assembler* a = theAssembler = new Assembler(100, 100, false, true);

    a->leal(no_reg, initial_count_addr, VMAddressOperand, edx);
    countAddr_offset = a->offset() - sizeof(int32);
    a->movl(edx, 0, NumberOperand,  eax);
    a->incl(eax);
    a->movl(eax,  edx, 0, NumberOperand);
    a->cmpl(0xabcdef01, NumberOperand,   eax); 
    limit_offset = a->offset() - sizeof(int32);
    a->jne(0x87654321, CodeAddressOperand);
    nmAddr_offset = a->offset() - sizeof(int32);
    a->call((int32)Recompile_stub, VMAddressOperand);
    recompileStub_offset = a->offset() - sizeof(int32);

    instsSize = a->offset();
    pattern = (pc_t)AllocateHeap(instsSize, "countStub pattern");
    copy_bytes(a->instsStart, pattern, instsSize);
    *(int32*)&pattern[recompileStub_offset] -= pattern - a->instsStart; // fixup the call
    a->finalize();
    theAssembler = oldAssembler;    
  }
开发者ID:AaronNGray,项目名称:self,代码行数:33,代码来源:countPattern_i386.cpp

示例5: translatefetch

/**
 * This translates one of the fetches
 *
* a - the Assembler object
* p - 1 if this is fetch 'b',0 if 'a'
* vmem - VM memory
* xmem - Execution Memory
* vstaddr - DCPU Address of page start in vmem
* vsaddr - DCPU Address of instruction in vmem
* has_other_nw - 1 if the previous fetch used a nextword
* 
* returns - 1 if this inst uses a nextword
*/
int translatefetch(Assembler &a,int p,char * vmem,char * xmem,uint16_t vstaddr,
		uint16_t vsaddr,int has_other_nw){

	uint16_t inst = *(uint16_t*)(vmem+(2*vsaddr));    //figure out the virtual address of this instruction
	char typ = p?(inst>>6)&0x1f:0x3f&inst; //mask and bitshift the argument from the instruction
	GPReg tempq = p?rbx:rax;
	GPReg tempw = p?bx:ax;
	printf("Got inst %x and typ %x\n",inst&0xffff,typ&0x3f);
	uint16_t nw;
	if(has_other_nw){
		nw = *(uint16_t*)(vmem+(2*(vsaddr+2)));
	}else{
		nw = *(uint16_t*)(vmem+(2*(vsaddr+1)));
	}
	if(typ<0x18){ //Uses at least a gpreg
		GPReg reg = getreg(typ);
		if(typ<0x08){ //Load gpreg
			a.mov(tempq,reg);
			return 0;
		}else if(typ<0x10){ //Load [gpreg]
			a.mov(tempw,ptr(rdi,reg,1));
			return 0;
		}else{//load [gpreg+nw]
			a.mov(tempq,imm((sysint_t)nw));
			a.add(tempq,reg);
			a.mov(tempw,ptr(rdi,rax,1));
			return 1;
		}
	}if(typ==0x18){ //Is pop
		a.inc(rdx);
		a.mov(tempw,ptr(rdi,rdx,1));
		return 0;
	}if(typ==0x19){ //Is peek
		a.mov(tempw,ptr(rdi,rdx,1));
		return 0;
	}if(typ==0x1a){ //Is pick
		a.mov(tempq,imm((sysint_t)nw));
		a.add(tempq,rdx);
		a.mov(tempw,ptr(rdi,rax,1));
		return 1;
	}if(typ==0x1b){ //SP
		a.mov(tempw,dx);
		return 0;
	}if(typ==0x1c){ //PC
		Label lbl = a.newLabel();
		a.bind(lbl);
		a.lea(tempq,Mem(lbl,1)); //This is somehow the same as 'lea rax,[rip]'
		a.sub(tempq,rbp);		//Subtract the start of xmem from the current ex addr
		a.shr(tempq,imm(XMEM_TO_VMEM)); //Shift the bits down
		return 0;
	}if(typ==0x1d){ //EX
		a.mov(p?rbx:rax,rcx);
		return 0;
	}if(typ==0x1e){ //[nw]
		a.mov(tempq,imm((sysint_t)nw));
		a.mov(tempw,ptr(rdi,rax,1));
		return 1;
	}if(typ==0x1f){ //nextword
		a.mov(tempw,imm((sysint_t)nw));
		return 1;
	}else{ //Is literal
		int16_t v = 0xffff + (int16_t)(typ-0x20);
		a.mov(tempw,imm((sysint_t)v));
		return 0;
	}
	return 0;
}
开发者ID:baobrien,项目名称:dcpu-trx,代码行数:80,代码来源:translate.cpp

示例6: NumGradientFunc

 NumGradientFunc(Assembler& assembler,
                 const Array_<AssemblyConditionIndex>& numGoals) 
 :   Differentiator::GradientFunction(assembler.getNumFreeQs()),
     assembler(assembler), numGoals(numGoals) {}
开发者ID:BrianZ1,项目名称:simbody,代码行数:4,代码来源:Assembler.cpp

示例7: visitNativeCallNode

void Generator::visitNativeCallNode(NativeCallNode *node)
{
    static XMMReg dregs[] = {
        xmm0 , xmm1 , xmm2 , xmm3 ,
        xmm4 , xmm5 , xmm6 , xmm7 ,
        xmm8 , xmm9 , xmm10, xmm11,
        xmm12, xmm13, xmm14, xmm15 };
    static GPReg cregs[] = {
        ndi, nsi, ndx, ncx, r8, r9
    };
    Assembler asmb;
    asmb.push(nbp);
    asmb.mov(nbp, nsp);
    if (node->nativeSignature().size() > 1)
    {
        asmb.mov(nax, ndi);
        size_t dregpos = 0, cregpos = 0, shift = 0, it = 1;
        for (; it < node->nativeSignature().size(); ++it)
        {
            if (node->nativeSignature()[it].first == VT_DOUBLE)
            {
                asmb.movsd(dregs[dregpos], qword_ptr(nax, shift));
                shift += sizeof(double);
                ++dregpos;
            }
            else
            {
                asmb.mov(cregs[cregpos], qword_ptr(nax, shift));
                ++cregpos;
                if (node->nativeSignature()[it].first == VT_INT) shift += sizeof(int64_t);
                else shift += sizeof(char const *);
            }
        }
    }
    asmb.call(imm((sysint_t)node->info()));
    asmb.mov(nsp, nbp);
    asmb.pop(nbp);
    asmb.ret();
	uint16_t id = m_code->makeNativeFunction(node->nativeName(),
	                                         node->nativeSignature(),
	                                         asmb.make());
	bytecode()->addInsn(BC_CALLNATIVE);
	bytecode()->addInt16(id);
	bytecode()->addInsn(BC_RETURN);
}
开发者ID:nvmd,项目名称:spbau-mathvm,代码行数:45,代码来源:generator.cpp

示例8: main

int main(int argc, char* argv[]) {
  std::string file_name;
  if (argc < 2) {
    std::cerr << "please specify the file name" << std::endl;
    return 1;
  }
  file_name = argv[1];
  std::ifstream infile;
#ifdef _MSC_VER
  // handling file names with non-ascii characters
  wchar_t *wcstring = new wchar_t[file_name.size()+1];
  setlocale(LC_ALL, ".OCP");
  mbstowcs(wcstring, file_name.c_str(), file_name.size()+1);
  infile.open(wcstring);
  delete[] wcstring;
  setlocale(LC_ALL, "");
#else  // _MSC_VER
  infile.open(file_name.c_str());
#endif  // _MSC_VER
  if (!infile.is_open()) {
    std::cerr << "cannot open the input file" << std::endl;
    return 1;
  }
  SUTModel sut_model;
  Assembler assembler;
  try {
    ct::lexer lexer(&infile);
    assembler.setErrLogger(boost::shared_ptr<ErrLogger>(new ErrLogger_Cerr()));
    yy::ct_parser parser(lexer,
                         sut_model.param_specs_,
                         sut_model.strengths_, 
                         sut_model.seeds_,
                         sut_model.constraints_,
                         assembler);
    parser.parse();
  } catch (std::runtime_error e) {
    std::cerr << e.what() << std::endl;
  } catch (...) {
    std::cerr << "unhandled exception when parsing input file" << std::endl;
    std::cerr << "exiting" << std::endl;
    return 1;
  }
  if (assembler.numErrs() > 0) {
    std::cerr << assembler.numErrs() << " errors in the input file, exiting" << std::endl;
    return 2;
  }
  std::cout << "successfully parsed the input file" << std::endl;
  std::cout << "# parameters:  " << sut_model.param_specs_.size() << std::endl;
  std::cout << "# strengths:   " << sut_model.strengths_.size() << std::endl;
  std::cout << "# seeds:       " << sut_model.seeds_.size() << std::endl;
  std::cout << "# constraints: " << sut_model.constraints_.size() << std::endl;
  
  std::vector<RawStrength> raw_strengths;
  TuplePool tuple_pool;
  for (std::size_t i = 0; i < sut_model.strengths_.size(); ++i) {
    attach_2_raw_strength(sut_model.strengths_[i], raw_strengths);
  }
  for (std::size_t i = 0; i < raw_strengths.size(); ++i) {
    Tuple tuple;
    for (std::size_t j = 0; j < raw_strengths[i].size(); ++j) {
      tuple.push_back(PVPair(raw_strengths[i][j], 0));
    }
    if (tuple.size() <= 0) {
      continue;
    }
    do {
      tuple_pool.insert(tuple);
    } while (tuple.to_the_next_tuple(sut_model.param_specs_));
  }
  std::cout << "# target combinations: " << tuple_pool.size() << std::endl;
  
  TuplePool forbidden_tuple_pool;
  for (std::size_t i = 0; i < sut_model.constraints_.size(); ++i) {
    std::set<std::size_t> rel_pids;
    sut_model.constraints_[i]->touch_pids(sut_model.param_specs_, rel_pids);
    Tuple tuple;
    for (std::set<std::size_t>::const_iterator iter = rel_pids.begin(); iter != rel_pids.end(); iter++) {
      tuple.push_back(PVPair(*iter, 0));
    }
    do {
      EvalType_Bool result = sut_model.constraints_[i]->Evaluate(sut_model.param_specs_, tuple);
      if (!result.is_valid_ || !result.value_) {
        forbidden_tuple_pool.insert(tuple);
      }
    } while (tuple.to_the_next_tuple_with_ivld(sut_model.param_specs_));
  }
  std::cout << "# forbidden combinations: " << forbidden_tuple_pool.size() << std::endl;
  return 0;
}
开发者ID:yanyige,项目名称:ct_common,代码行数:89,代码来源:example.cpp

示例9: copy_info

void CSingleCodeComplicated::copy_info(InstructionsInfo *info,Assembler a)
{
	info->code_buf = new unsigned char[a.getCodeSize()];
	memcpy(info->code_buf,a.getCode(),a.getCodeSize());
	info->code_size = a.getCodeSize();
}
开发者ID:601040605,项目名称:WProtect,代码行数:6,代码来源:SingleOutOfOrder.cpp

示例10: Assembler

 void AgingStub::initPattern() {
   Assembler* a = new Assembler(oopSize, oopSize, false, true);
   a->AddI(G0, 0, Temp1);
   add_inst = *(int32*)a->instsStart;
   a->finalize();
 }
开发者ID:AdamSpitz,项目名称:self,代码行数:6,代码来源:countStub_sparc.cpp

示例11: DWAlign

/// <summary>
/// Inject pure IL image.
/// </summary>
/// <param name="netVersion">NET runtime version to use</param>
/// <param name="netAssemblyPath">Path to image</param>
/// <param name="netAssemblyMethod">Method to call</param>
/// <param name="netAssemblyArgs">Arguments passed into method</param>
/// <param name="returnCode">Return code</param>
/// <returns>true on success</returns>
bool ProcessModules::InjectPureIL( const std::wstring& netVersion, 
                                   const std::wstring& netAssemblyPath,
                                   const std::wstring& netAssemblyMethod, 
                                   const std::wstring& netAssemblyArgs, 
                                   DWORD& returnCode )
{
    // split netAssemblyMethod string into class and method names
    size_t idx = netAssemblyMethod.find_last_of( '.' );
    if (idx == std::wstring::npos)
        return false;

    std::wstring MethodName = netAssemblyMethod.substr( idx + 1 );
    std::wstring tmp = netAssemblyMethod;
    tmp.erase( idx );
    std::wstring ClassName = tmp;

    auto address = _memory.Allocate( 0x10000 );

    size_t offset = 4;

    size_t address_VersionString, address_netAssemblyDll, address_netAssemblyClass, 
           address_netAssemblyMethod, address_netAssemblyArgs;

    const std::wstring* strArr[] = { &netVersion, &netAssemblyPath, &ClassName, &MethodName, &netAssemblyArgs };

    size_t* ofstArr[] = { &address_VersionString, &address_netAssemblyDll, &address_netAssemblyClass, 
                          &address_netAssemblyMethod, &address_netAssemblyArgs };

    // Write strings
    for (int i = 0; i < ARRAYSIZE( strArr ); i++)
    {
        size_t len = strArr[i]->length();

        *(ofstArr[i]) = address.ptr<size_t>() + offset;

        // runtime version to use
        if (address.Write( offset, len * sizeof(wchar_t) + 2, strArr[i]->c_str( ) ) != STATUS_SUCCESS)
        {
            returnCode = 5;
            return false;
        }

        offset = DWAlign( offset + len * sizeof(wchar_t) + 2 );
    }

    offset += 4;

    GUID GArray[] = { CLSID_CLRMetaHost, IID_ICLRMetaHost, IID_ICLRRuntimeInfo, CLSID_CLRRuntimeHost, IID_ICLRRuntimeHost };

    // COM object GUIDs
    if (address.Write( offset, sizeof(GArray), GArray ) != STATUS_SUCCESS)
    {
        returnCode = 10;
        return false;
    }

    size_t address_CLSID_CLRMetaHost    = address.ptr<size_t>() + offset + 0;
    size_t address_IID_ICLRMetaHost     = address.ptr<size_t>() + offset + 0x10;
    size_t address_IID_ICLRRuntimeInfo  = address.ptr<size_t>() + offset + 0x20;
    size_t address_CLSID_CLRRuntimeHost = address.ptr<size_t>() + offset + 0x30;
    size_t address_IID_ICLRRuntimeHost  = address.ptr<size_t>() + offset + 0x40;

    offset += sizeof(GArray);

    std::wstring libName = L"mscoree.dll";

    NameResolve::Instance().ResolvePath( libName, L"", L"", NameResolve::EnsureFullPath, 0 );

    auto pMscoree = Inject( libName );
    if(!pMscoree)
    {
        returnCode = 15;
        return false;
    }

    // CLRCreateInstance address
    size_t CreateInstanceAddress = (size_t)GetExport( pMscoree, "CLRCreateInstance" ).procAddress;

    // Scary assembler code incoming!
    Assembler a;
    AsmJitHelper ah( a );
    AsmStackAllocator sa( 0x30 );   // 0x30 - 6 arguments of ExecuteInDefaultAppDomain

    // Stack will be reserved manually
    ah.EnableX64CallStack( false );

    Label L_Exit = a.newLabel();
    Label L_Error1 = a.newLabel();
    Label L_Error2 = a.newLabel();
    Label L_Error3 = a.newLabel();
    Label L_Error4 = a.newLabel();
//.........这里部分代码省略.........
开发者ID:CaptainBigSmoke,项目名称:Blackbone,代码行数:101,代码来源:ProcessModules.cpp

示例12: TEST

TEST(Assembler, DISABLED_canAssembleNOPInstruction)
{
	Assembler a;
	BytesArray code = a.getOpCodes("NOP");
	ASSERT_EQ(0x00,code.getByteAtIndex(0));
}
开发者ID:radx64,项目名称:8051Emulator,代码行数:6,代码来源:AssemblerTests.cpp

示例13: Assembler

  void CountCodePattern::initComparing() {
    instsSize = 13 * 4;
    // 0: sethi count_addr, Temp1
    // 1: ld    [Temp1+lo(count_addr)], Temp2
    // 2: setHi limit, Temp1
    // 3: inc   Temp2
    // 4: cmp   Temp2, Temp1
    // 5: sethi count_addr, Temp1
    // 6: st    Temp2, [Temp1+lo(count_addr)]
    // 7: beq   10
    // 8: sethi jump_addr, Temp1
    // 9: jmpl   Temp1 + low(jump_addr), g0
    //10: sethi recompile_addr, Temp2
    //11: jmpl   Temp2 + low(recompile_addr), linkReg
    //12: nop
    countAddr_offset = 0;
    countAddr_offset2 = 5;
    ld_offset = 1;
    st_offset = 6;
    nm_sethi_offset = 8;
    nm_jmp_offset = 9;
    limit_sethi_offset = 2;
    recompile_offset = 10;

    Assembler* a = new Assembler(instsSize, instsSize, false, true);
    a->SetHiA(0, Temp1);
    a->LoadI(Temp1, 0, Temp2);
    a->SetHiA(0, Temp1);
    a->AddI(Temp2, 1, Temp2);
    a->SubCCR(Temp2, Temp1, G0);
    a->SetHiA(0, Temp1);
    a->StoreI(Temp1, 0, Temp2);
    Label* l = a->BgeForward(false);
    a->SetHiX(0, CodeAddressOperand, Temp1);
    a->JmpLC(Temp1, 0, G0);
    l->define();
    a->SetHiP(Memory->code->trapdoors->Recompile_stub_td(), Temp2);
    a->JmpLP(Temp2, Memory->code->trapdoors->Recompile_stub_td(), RecompileLinkReg);
    a->Nop();
    pattern = (pc_t)AllocateHeap(instsSize, "countStub pattern");
    copy_words((int32*)a->instsStart, (int32*)pattern, instsSize / 4);
    a->finalize();
  }
开发者ID:AaronNGray,项目名称:self,代码行数:43,代码来源:countPattern_sparc.cpp

示例14: main

int main(int argc, char* argv[])
{
  using namespace AsmJit;

  // ==========================================================================
  // Create assembler.
  Assembler a;

  // Log assembler output.
  FileLogger logger(stderr);
  logger.setLogBinary(true);
  a.setLogger(&logger);

  // We don't want to crash :)
  a.ret();

  // Instructions.
  a.adc(nax,nax);
  a.adc(nax,sysint_ptr(nax));
  a.adc(nax,0);
  a.adc(sysint_ptr(nax),nax);
  a.adc(sysint_ptr(nax),0);
  a.add(nax,nax);
  a.add(nax,sysint_ptr(nax));
  a.add(nax,0);
  a.add(sysint_ptr(nax),nax);
  a.add(sysint_ptr(nax),0);
  a.and_(nax,nax);
  a.and_(nax,sysint_ptr(nax));
  a.and_(nax,0);
  a.and_(sysint_ptr(nax),nax);
  a.and_(sysint_ptr(nax),0);
  a.bswap(nax);
  a.bt(nax,nax);
  a.bt(sysint_ptr(nax),nax);
  a.bt(nax,0);
  a.bt(sysint_ptr(nax),0);
  a.btc(nax,nax);
  a.btc(sysint_ptr(nax),nax);
  a.btc(nax,0);
  a.btc(sysint_ptr(nax),0);
  a.btr(nax,nax);
  a.btr(sysint_ptr(nax),nax);
  a.btr(nax,0);
  a.btr(sysint_ptr(nax),0);
  a.bts(nax,nax);
  a.bts(sysint_ptr(nax),nax);
  a.bts(nax,0);
  a.bts(sysint_ptr(nax),0);
  a.call(nax);
  a.call(sysint_ptr(nax));
  a.cbw();
  a.cwde();
  a.clc();
  a.cld();
  a.cmc();
  a.cmp(nax,nax);
  a.cmp(nax,sysint_ptr(nax));
  a.cmp(nax,0);
  a.cmp(sysint_ptr(nax),nax);
  a.cmp(sysint_ptr(nax),0);
  a.cmpxchg(nax,nax);
  a.cmpxchg(sysint_ptr(nax),nax);
  a.cmpxchg8b(ptr(nax));
  a.cpuid();
  a.dec(nax);
  a.dec(sysint_ptr(nax));
  a.div(nax);
  a.div(sysint_ptr(nax));
  a.idiv(nax);
  a.idiv(sysint_ptr(nax));
  a.imul(nax);
  a.imul(sysint_ptr(nax));
  a.imul(nax,nax);
  a.imul(nax,sysint_ptr(nax));
  a.imul(nax,0);
  a.imul(nax,nax,0);
  a.imul(nax,sysint_ptr(nax),0);
  a.inc(nax);
  a.inc(sysint_ptr(nax));
  a.int3();
  a.lea(nax,sysint_ptr(nax));
  a.mov(nax,nax);
  a.mov(nax,sysint_ptr(nax));
  a.mov(nax,0);
  a.mov(sysint_ptr(nax),nax);
  a.mov(sysint_ptr(nax),0);
  a.movsx(nax,al);
  a.movsx(nax,byte_ptr(nax));
  a.movzx(nax,al);
  a.movzx(nax,byte_ptr(nax));
  a.mul(nax);
  a.mul(sysint_ptr(nax));
  a.neg(nax);
  a.neg(sysint_ptr(nax));
  a.nop();
  a.not_(nax);
  a.not_(sysint_ptr(nax));
  a.or_(nax,nax);
  a.or_(nax,sysint_ptr(nax));
//.........这里部分代码省略.........
开发者ID:Falaina,项目名称:AsmJit-Python,代码行数:101,代码来源:testopcode.cpp

示例15: getAssembler

bool Compiler::isLabelValid(uint32_t id) const noexcept {
  Assembler* assembler = getAssembler();
  if (assembler == nullptr) return false;

  return static_cast<size_t>(id) < assembler->getLabelsCount();
}
开发者ID:AmesianX,项目名称:asmjit,代码行数:6,代码来源:compiler.cpp


注:本文中的Assembler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。