Author Topic: how use a label table to write a switch.  (Read 18286 times)

A. Buisson

  • Guest
how use a label table to write a switch.
« on: January 19, 2006, 09:57:13 AM »
hi,

i try to port an asm source code from a .asm write to ML under windows to a .asm which compil with nasm under linux and windows.

i have the following problem : in ML, i can write
switchtable LABEL DWORD DWORD OFFSET label00, OFFSET label01

jmp switchtable[eax] ; eax is my test condition

but in nasm all is label so how rewrite this 2 line ?
at this time i have use nasm local label to label00 and label01

thanks

nobody

  • Guest
Re: how use a label table to write a switch.
« Reply #1 on: January 19, 2006, 10:17:02 AM »
I don't think you'd want local labels for this. Just:

switchtable dd label00, label01, label02...

Probably want to multiply eax by 4 somewhere along the line...
jmp [switchtable + eax * 4]
Something like that...
Best,
Frank