You mean using "function-like" macros is avoidable
Whoops - Yes I did
The macro I suggested is a good one in systems that are expensive to do a branch/jump - It was cut and paste from some code I had.
You were right in saying that it takes longer to do (certainly on my processor) -
It performs 5 operations to determine the min, when 1 is enough (or is it 2?)
Code:
k = (i<j) ? i : j;
00401321 call 0x401740 <__main>
00401326 movb $0xfa,0xc(%esp)
0040132B movb $0x64,0xd(%esp)
00401330 mov 0xc(%esp),%dl
00401334 mov 0xd(%esp),%al
00401338 cmp %dl,%al
0040133A jle 0x40133e <main+38>
0040133C mov %dl,%al
0040133E mov %al,0xe(%esp)
00401342 mov $0x0,%eax
k = (y ^ ((x ^ y) & -(x < y)));
00401321 call 0x401750 <__main>
00401326 movb $0xfa,0xc(%esp)
0040132B movb $0x64,0xd(%esp)
00401330 mov 0xd(%esp),%al
00401334 mov 0xc(%esp),%dl
00401338 xor %eax,%edx
0040133A mov 0xc(%esp),%al
0040133E cmp 0xd(%esp),%al
00401342 setl %al
00401345 neg %eax
00401347 and %edx,%eax
00401349 xor 0xd(%esp),%al
0040134D mov %al,0xe(%esp)
00401351 mov $0x0,%eax
The ? operator was much more efficient (with 6 lines of assembly as compared to 10 lines of assembly)
Also, you forgot to put the (absolutely necessary) parentheses around your parameters in the macro definition.
Whoops again - Thank-you for pointing that out