previous | start | next

set instructions

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    
  1.           cmpl %eax, %edx
              setl %al
              movzbl %al, %eax
           
    
  2.           cmpw %ax, %dx
              setge %al
              movzbl %al, %eax
           
    
  3.           cmpl %al, %dl
              setb %al
              movzbl %al, %eax
           
    
  4.           cmpl %eax, %edx
              setne %al
              movzbl %al, %eax
           
    


previous | start | next