From f4f5f027f29318b4e878d15342389da50c7c5e68 Mon Sep 17 00:00:00 2001
From: Lauchmelder <robert.trololo@gmail.com>
Date: Thu, 20 Jan 2022 13:06:34 +0100
Subject: [PATCH] clippy command works

---
 include/string.h |  3 +++
 src/kernel.c     | 15 ++++++++-------
 src/string.c     | 12 ++++++++++++
 3 files changed, 23 insertions(+), 7 deletions(-)
 create mode 100644 include/string.h
 create mode 100644 src/string.c

diff --git a/include/string.h b/include/string.h
new file mode 100644
index 0000000..eba99dd
--- /dev/null
+++ b/include/string.h
@@ -0,0 +1,3 @@
+#pragma once
+
+int strcmp(const char* str1, const char* str2);
\ No newline at end of file
diff --git a/src/kernel.c b/src/kernel.c
index de1d5ab..bc9fd97 100644
--- a/src/kernel.c
+++ b/src/kernel.c
@@ -1,5 +1,6 @@
 #include "io.h"
 #include "convert.h"
+#include "string.h"
 
 void print_clippy();
 
@@ -24,19 +25,19 @@ void main()
     {
         uart_puts("\n\nPlease enter first operand\n");
         uart_puts("📎 "); 
-        int a = stoi(uart_gets(buffer));
-
-        uart_puts("\nPlease enter second operand\n");
-        uart_puts("📎 "); 
         uart_gets(buffer);
-
-        if(buffer == "clippy")
+        
+        if(!strcmp(buffer, "clippy"))
         {
             print_clippy();
             continue;
         }
 
-        int b = stoi(buffer);
+        int a = stoi(buffer);
+
+        uart_puts("\nPlease enter second operand\n");
+        uart_puts("📎 "); 
+        int b = stoi(uart_gets(buffer));
 
         uart_puts("\n");
         uart_puts(itoa(a, buffer));
diff --git a/src/string.c b/src/string.c
new file mode 100644
index 0000000..3b4c903
--- /dev/null
+++ b/src/string.c
@@ -0,0 +1,12 @@
+#include "string.h"
+
+int strcmp(const char* str1, const char* str2)
+{
+    while(*str1)
+    {
+        int diff = *str1++ - *str2++;
+        if(diff) return diff;
+    }
+
+    return 0;
+}
\ No newline at end of file