汇编语言实现:
xor ebx, ebx
cmp eax, [input1]
setg bl ; if (eax > [input1]) set bl = 0x01;
neg ebx ;
neg 1 = 0xffffffff. neg is the arithmatich 'negate' operation
mov ecx, ebx
and
ecx, eax
not ebx ; not 0 = 0xffffffff, not 0xffffffff = 0
and ebx, [input1]
or ecx, ebx
C语言实现完全就是从汇编翻译过来的,^_^
#include
int
main() {
int a, b, flag, result;
scanf("%d %d", &a,
&b);
flag = a > b;
flag = -flag;
result = flag &
a;
result |= ((~flag) & b);
printf("\nbigger one: %d\n",
result);
return 0;
}
阅读(2519) | 评论(0) | 转发(0) |