<div dir="ltr">Hello,<div><br></div><div>I am trying to generate the binary of my implemented vector load instruction whose assembly is similar to x86 as follows:</div><div><br></div><div><span style="font-size:12.8px">P_128B_LOAD_DWORD</span><span style="font-size:12.8px;white-space:pre-wrap">     </span><span style="font-size:12.8px">R_0_R1024b_0, pword ptr [rip + b] </span><br></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">I am able to get the required fields of the instruction by using  MI.getOperand(index) in x86mccodeemitter.cpp file. it works fine for register operands as</span></div><div><span style="font-size:12.8px">std::string reg_name=Ctx.getRegisterInfo()->getName(MI.getOperand(0).getReg());</span><br></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">but for obtaining the immediate field immediate operand? what should i do? i came to know by using gdb that there are 6 operands involved in this vector load instruction. i read each operand 1 by 1.  </span><span style="font-size:12.8px">MI.getOperand(0) gives destination register, </span><span style="font-size:12.8px">MI.getOperand(1) gives RIP.  there is some index where </span><span style="font-size:12.8px"> </span><span style="font-size:12.8px">MI.getOperand(index) i get immediate type value but that value is always 1. i have tested for other instructions as well.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">then, MI.getOperand(4) gives kexpr type value which is in hex also another value come in this same expr object with name immediate which is the decimal equivalent of this hex value. this value keeps changing for different instructions. i assume kexpr is the value of the immediate i am looking for. so i obtained the immediate from kexpr object convert it into hex then put it in the immediate field of my encoded instruction. something as follows:</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">for example</span></div><div><span style="font-size:12.8px">MI.getOperand(4)</span><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">kexpr field;</span></div><div><span style="font-size:12.8px">MI.getOperand(4).getExpr()=</span><span style="font-size:12.8px">0x3067980, its immediate=</span><span style="font-size:12.8px">50755968)decimal</span></div><div><br></div><div><div style="font-size:12.8px">i used this value <span style="font-size:12.8px">50755968)decimal which is equivalent to </span><span style="font-size:12.8px">0x3067980,  as an immediate field of my instruction.</span></div></div><div style="font-size:12.8px"><span style="font-size:12.8px"><br></span></div><div style="font-size:12.8px"><span style="font-size:12.8px"><br></span></div><div style="font-size:12.8px"><span style="font-size:12.8px">Is it correct? please help me.</span></div><div style="font-size:12.8px"><span style="font-size:12.8px"><br></span></div><div style="font-size:12.8px"><span style="font-size:12.8px">Thank You</span></div><div style="font-size:12.8px"><span style="font-size:12.8px"><br></span></div><div style="font-size:12.8px">Regards</div></div>