summaryrefslogtreecommitdiff
path: root/3/6_control/comp.c
diff options
context:
space:
mode:
authorMike Vink <mike@pionative.com>2024-05-22 08:49:29 +0200
committerMike Vink <mike@pionative.com>2024-05-22 08:49:29 +0200
commit51169f5f9ab178a4ddfe9dac461405a71c9c0f94 (patch)
tree0b6bb0c6c31ee27361b28e2c5993f362c1cc95e2 /3/6_control/comp.c
parent77f19e4a89d8dec97930c5e237139734c5fb3365 (diff)
organise
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;
+}
+