I am trying to get out of using .if/.endif and code without them. But after reading some threads, I found if I do the jmps/cmps wrong, I could affect the speed.

is there any differance between:
What I am using now:


cmp UseTool, 5
jne @F
mov ToolName, offset dllMl
jmp DeleteIt

@@:
cmp UseTool, 6
jne @F
mov ToolName, offset dllCvtres
jmp DeleteIt
.
.
.
DeleteIt:
.
.
.

and
This is something from one of those jump table or whatnot threads:


cmp UseTool, 5
je SetMl
cmp UseTool, 6
je SetCvtres

SetMl:
mov ToolName, offset dllMl
jmp DeleteIt

SetCvtres:
mov ToolName, offset dllCvtres
jmp DeleteIt

They both look the same to me. Are there any differances?
Posted on 2003-01-22 14:04:15 by Gunner
No.

In the second bit of code, failing both will execute as if UseTool were 5
You need an unconditional jump to deleteit
Or alternativly:



cmp UseTool, 5
je SetMl
cmp UseTool, 6
jne DeleteIt
; Invert jump condition, so default is DeleteIt,
; and fall through i.e. not jump to SetCvtres
SetCvtres:
mov ToolName, offset dllCvtres
jmp DeleteIt

SetMl:
mov ToolName, offset dllMl
jmp DeleteIt


You may also want to look at cmov if you are certain it will execute on a PPro or above.

Mirno
Posted on 2003-01-22 14:39:31 by Mirno