Computed gotos on Reddit
Walter Bright
newshound2 at digitalmars.com
Wed Jul 25 12:58:57 PDT 2012
On 7/25/2012 12:52 PM, Dmitry Olshansky wrote:
> On 25-Jul-12 21:47, Walter Bright wrote:
>> On 7/25/2012 10:29 AM, Dmitry Olshansky wrote:
>>>> Is it possible you could code it up and test it using inline asm?
> ...
>
>
>>> Any tips on which spare registers to use (I guess ecx is no go, as
>>> there is
>>> 'this' pointer present) ?
>>
>> I wouldn't worry about it. EAX is good.
>>
> OK. I'm almost there, here is what I have:
> //my byte code sets 8-bit to discern code/data
> uint c = re.ir[t.pc].code - 128;
> //no idea how to code the above in asm
> //.code is { return x & mask; } property
> asm{
> mov EAX, c;
> lea EAX, L_jumptable[EAX][EAX*4];
> jmp EAX;
> }
> L_jumptable:
> mixin(`asm{`
> ~ genJumpTable()
> ~ `} `);
>
> So I have proper table generated and it all goes fine untill I get:
>
> std\regex.d(5118): Error: undefined identifier 'L_jumptable'
>
I was afraid of that. You may have to approximate it by loading the address of
L_jumptable into a register and adding it in instead of using the addressing
mode. Then, add those extra instructions as dummies into the other path.
More information about the Digitalmars-d
mailing list