Well, now I have stored the memory location, where I need to insert my value, in the EDX register. I am not using force_reg() now. I have stored the value to be inserted in a rtx type register. But how do I set the value of memory location in EDX with the value stored in a rtx type register? Is there any library function which will allow me to do so? Here is my code: if (frame_pointer_needed) { rtx r, set1,m1,edx,insn,temp; //Here hard frame pointer is pushed onto the stack insn = emit_insn (gen_push (hard_frame_pointer_rtx)); RTX_FRAME_RELATED_P (insn) = 1; //Here hard frame pointer is updated insn = emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx); RTX_FRAME_RELATED_P (insn) = 1; //my code starts from here. r = cfun->machine->force_align_arg_pointer; r = gen_rtx_PLUS (Pmode, r, -8); r = gen_rtx_MEM (Pmode, r); edx = gen_rtx_REG (Pmode, DX_REG); emit_move_insn(edx,r); //EDX now contains the memory location //Here I have stored the return address pushed on the stack in ret_addr //So the following code generates a rtx variable //which has the value ret_addr XOR hard_frame_pointer m1 = simplify_binary_operation(XOR, Pmode, ret_addr, hard_frame_pointer_rtx); //now how to set memory location in edx with value m1??? Is there any function //to do so.If not, please suggest me some other way of doing so. } On Wed, Apr 14, 2010 at 7:44 PM, Ian Lance Taylor <iant@xxxxxxxxxx> wrote: > Vaibhav Shrimali <vaibhav.shrimali@xxxxxxxxx> writes: > >> I can use a hard register for this task. But will it allow me to >> modify the memory location, between original return address and saved >> frame pointer, stored in it? > > My point about the hard register was that you can't call force_reg > after register allocation. > >> I think it will be just saved in the "saved registers" area of stack. >> The assembly conversion of the prologue I need is: >> >> POP EAX ; new prologue start >> PUSH EAX ; unencrypted return address >> PUSH EAX ; duplicate return address >> PUSH EBP ; standard prologue >> MOVE EBP, ESP >> XOR [EBP+4], EBP ; [EBP+4] has EIP and XOR encryptes ret addr(EIP) >> >> I want to know the function which allows me to write a value at a >> memory address specified by a variable (generated by gen_rtx_MEM). >> I thought force_reg is the one. Now, can I use ebx/ecx/...etc register >> for the purpose. >> OR will copy_to_mode_reg() function do the job? >> OR is there any other function to do the job? > > You need to copy your memory location into a register. force_reg > copies it into a pseudo-register. You need to copy it into a chosen > hard register. Use emit_move_insn. > > Ian > -- Vaibhav Shrimali BTech(ICT), DA-IICT Gandhinagar