Hi,

The parameters of a function call in x86-64 are first placed in _registers_
in this order: Rdi, Rsi, Rdx, Rcx, R8, R9.  For example:

uint64_t myPseudoInst( void *ptr1, void *ptr2 );
//ptr1 -> Rdi
//ptr2 -> Rsi

So if you have your address as a void pointer (or any other pointer type),
the pointer value is placed in Rdi when the function is called. These are
in the same order when the corresponding gem5 function in the PseudoInst
namespace is called:

uint64_t PseudoInst::myPseudoInst( ThreadContext *tc, void *ptr1, void*
ptr2 ) { ... }

You generally don't need to worry about this order except for modifying the
two_byte_opcodes.isa file for your pseudo instruction.

This order of registers is the x86-64 System V calling convention, which
Linux uses. You can also search that for more information.

-- 
Matt Poremba
Ph.D. Candidate
354B IST Building
Pennsylvania State University
University Park, PA 16802


On Sat, Nov 9, 2013 at 3:05 PM, Xiaoyu Zheng <[email protected]> wrote:

> Hi all,
>
> I'm working on extending the x86 ISA by adding pseudo instructions. I
> wonder that how the pseudo instruction is translated to assembly language.
> I know that the pseudo inst in x86 is 0x0f 0x04, and I choose 0x54 as the
> opcode. Also, I want to pass an address as the input of the pseudo inst. Is
> that the address will be stored in a specific register or in the same
> binary code after the opcode I chose? If the input is stored in a specific
> register,which one is the register?
>
> Thanks a lot!
>
> With respects,
> Xiaoyu Zheng
>
> _______________________________________________
> gem5-users mailing list
> [email protected]
> http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
>
_______________________________________________
gem5-users mailing list
[email protected]
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users

Reply via email to