Computed gotos on Reddit
Dmitry Olshansky
dmitry.olsh at gmail.com
Wed Jul 25 13:07:58 PDT 2012
On 26-Jul-12 00:06, Dmitry Olshansky wrote:
> On 25-Jul-12 23:58, Walter Bright wrote:
>> 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.
> like this ?
> mov EDX, L_jumptable
> mov EAX, EDX[EAX][EAX*4]
Corrected typos. Still it doesn't take off.
--
Dmitry Olshansky
More information about the Digitalmars-d
mailing list