P
paul.at.gmail
I am starting experimenting with IL code generation for a Forth-like
stack-based language that uses the CLR evaluation stack as the
Parameter stack (i.e. not a call stack) and a separate array for the
call stack. Therefore I expect I must avoid the IL ret instruction,
which enforces an empty evaluation stack on method return. To achieve
this I need to perform an indirect branch or jump as suggested below.
Does anyone know how to achieve this indirect jump efficiently in IL?
..method private hidebysig static void MyMethod() cil managed
{
.entrypoint
.maxstack 2
stind stackPtr // push the return address on the seperate call stack
ldsfld stackPtr // increment the stack pointer
ldc.i4.1
add
stsfld stackPtr
:
..execute the method..
:
// I don't want to use ret therefore...
ldsfld stackPtr
ldc.i4.1
sub
stsfld stackPtr
ldind stackPtr
?? // bra indirect or similar required here
}
stack-based language that uses the CLR evaluation stack as the
Parameter stack (i.e. not a call stack) and a separate array for the
call stack. Therefore I expect I must avoid the IL ret instruction,
which enforces an empty evaluation stack on method return. To achieve
this I need to perform an indirect branch or jump as suggested below.
Does anyone know how to achieve this indirect jump efficiently in IL?
..method private hidebysig static void MyMethod() cil managed
{
.entrypoint
.maxstack 2
stind stackPtr // push the return address on the seperate call stack
ldsfld stackPtr // increment the stack pointer
ldc.i4.1
add
stsfld stackPtr
:
..execute the method..
:
// I don't want to use ret therefore...
ldsfld stackPtr
ldc.i4.1
sub
stsfld stackPtr
ldind stackPtr
?? // bra indirect or similar required here
}