[Mono-dev] Adding a new opcode - bis
Denis ERCHOFF
d_erchoff at hotmail.com
Thu Jul 27 18:24:37 EDT 2006
Hi,
I want to add a new opcode ( for educational purpose ) and i have some
questions.
Hi,
I resend this email because previously i did a reply on a precedent
email ( by lazyless, to do not look for the mailing list address in my
contacts folder ), and i saw that my ask was lost in another thread.
Now, i hope it will be correct :)
First i explain what i want to do :
I have a C struct :
struct MyStruct
{
int MyField;
}
In the managed code, i have a property of type IntPtr ( MyManagedProp ).
MyManagedProp is setup with a pointer to a MyStruct.
I defined a new opcode "myopcode" in the files opcodes.def. This opcode,
using a MyStruct pointer, must load the MyField value.
So, in the managed code i am pushing the MyManagedProp on the stack, i
am calling the myopcode which do some work. After i am calling an
internal C function taking an int argument.
I am thinking define the myopcode like the OP_STRLEN :
reg: OP_MYOPCODE (reg) { MONO_EMIT_LOAD_MEMBASE_OP (s, tree,
OP_LOADI4_MEMBASE, state->reg1,
state->left->reg1, G_STRUCT_OFFSET (MyStruct, MyField));
}
1) Because my IntPtr is stored on the managed stack, should i add a pop
command before the MONO_EMIT_LOAD_MEMBASE_OP ?
2) After MyField value is moved in a reg, i want to add a jit icall
using this value. Should i add a push command to push it on the stack ?
3) Can i add the the icall directly in the burg file as :
reg: OP_MYOPCODE (reg) { MONO_EMIT_LOAD_MEMBASE_OP (s, tree,
OP_LOADI4_MEMBASE, state->reg1,
state->left->reg1, G_STRUCT_OFFSET (MyStruct, MyField));
emit_call (cfg, code, MONO_PATCH_INFO_ABS, call->fptr);
}
4) Any comments to explain how mono choose and manage registers are
welcome :)
Thanks.
More information about the Mono-devel-list
mailing list