lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

Raja Mukherji wrote:
> I'm using Dynasm (which is part of LuaJIT) in an interpreter for my
> programming language Wrapl and would like to generate case tables,
> i.e. code that resembles:

It's good to know somebody makes use of it outside of LuaJIT. :-)

>    mov eax, Value
>    jmp [>1 + 4 * Value]

Make that:
  |  jmp [eax*4 + >1]

> I've been trying this using local labels, >2, >3, etc but all I get is
> 
> assembler-internal.dasc:650: error: bad mode or size in `<3':
> 	| .dword <3

These are addresses, so it's better to use:
  |  .aword <3, <4, <5, ...

You can also use PC labels (=>number) if you need more cases or a
dynamic number of cases. But you have to be careful not to
recycle the PC numbers of course.

In any case, you need an updated version of DynASM for this. I've
previously neglected to implement some of the possible mode
combinations, because I've never needed them. I've sent you a
replacement dasm_x86.lua in a private mail message.

Bye,
     Mike