jump table (improved?)

Dan Lewis Dan_member at pathlink.com
Sat Mar 18 04:01:09 PST 2006


Hi folks.  Here's a gimme for anyone out there writing a lexer.  Give it three
variables, and you have a tight jump table switch.  I'm about to port this over
to nasm to avoid the GC/Phobos overhead.  :p

asm
{
naked;
even;
cld;
mov	ECX,	strLength;
mov	ESI,	charP;
xor	EAX,	EAX;
L1:	lodsb;
jecxz	short EXIT_SUCCESS;
test	AL,	0x80;
jnz	short EXIT_BAD_CHAR;
lea	EBX,	[AL*4+jumpTableP]
jmp	EBX;
}





More information about the Digitalmars-d mailing list