summaryrefslogtreecommitdiff
path: root/3/6_control/comp.c
diff options
context:
space:
mode:
Diffstat (limited to '3/6_control/comp.c')
-rw-r--r--3/6_control/comp.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/3/6_control/comp.c b/3/6_control/comp.c
new file mode 100644
index 0000000..beba875
--- /dev/null
+++ b/3/6_control/comp.c
@@ -0,0 +1,36 @@
+#include <stdio.h>
+
+typedef char data_t;
+
+#define COMP <=
+
+// a in rdx, b in rsi
+//
+// cmpl %esi, %edi (Compare long (double word, or 4 bytes). (a - b) )
+// setl %al (set lower? %rax return value)
+//
+// COMP is <, and data_t is 32 bits so maybe int or unsigned int or float
+//
+// cmpw %si, %di (Compare word (a-b), short)
+// setge %al (Greater than or equal >=)
+//
+// cmpb %sil, %dil (Compare byte (a-b))
+// setbe %al (Comp <=)
+//
+// cmpq %rsi, %rdi (Compare 8 bytes quad words (long , double, char *))
+// setne %al
+int comp(data_t a, data_t b) {
+ return a COMP b;
+}
+
+#define TEST >
+
+int test(data_t a) {
+ return a TEST 0;
+}
+
+int main() {
+ printf("%x hello world", comp(1, 2));
+ return 0;
+}
+