The set instructions read the condition codes and store a byte 1 or byte 0 in the destination operand.
typedef intdata_t;
#define COMP <
int comp(data_t a, data_t b)
{
return a COMP b;
}
Assum a is in %edx and b is in %eax
Example | data_t | COMP |
---|---|---|
A | ||
B | ||
C | ||
D |
-
cmpl %eax, %edx setl %al movzbl %al, %eax
-
cmpw %ax, %dx setge %al movzbl %al, %eax
-
cmpl %al, %dl setb %al movzbl %al, %eax
-
cmpl %eax, %edx setne %al movzbl %al, %eax