I have the following flow in C:
// some stuff1
//................
if (something1) {
func1();
func2();
} else if (something2) {
func3();
func4()
I would say that it largely depends on how much code you have in these {...} blocks.
If there's limited code in them use:
cmp [some_struc], SOME_CONST
jne Else
{...}
jmp EndIf
Else:
cmp [some_struc], SOME_CONST2
jne EndIf
{...}
EndIf:
cmp rax, 0
If there's more code:
cmp [some_struc], SOME_CONST
jne Else
call Part1
jmp EndIf
Else:
cmp [some_struc], SOME_CONST2
jne EndIf
call Part2
EndIf:
cmp rax, 0
Part1:
{...}
ret
Part2:
{...}
ret
Best use call. I would not advice to jump to Part1 or Part2 and then jump back to EndIf.
This creates spaghetti code. Less readable and quickly becomes less maintainable.
As i see it you have two options:
call func.
the advantage is readability and more slick code as well as automatic jump back to where you called the function, but it will cost you the overhead of using a function (setting up the registers and pushing and popping the stack pointer).Anyway your conditional piece of code :
cmp [some_struc], SOME_CONST2
seems OK.