aboutsummaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2024-04-01 14:00:27 -0600
committerJack Sangdahl <[email protected]>2024-04-01 14:00:27 -0600
commit6fb34179efc44a8d3d39cfa7a514ecaaed83e9f8 (patch)
treef4712db984d79223630c4d9bd15a2a29a4d4ea38 /util.c
downloadsynacor_challenge-6fb34179efc44a8d3d39cfa7a514ecaaed83e9f8.tar.gz
synacor_challenge-6fb34179efc44a8d3d39cfa7a514ecaaed83e9f8.zip
initial
Diffstat (limited to 'util.c')
-rw-r--r--util.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/util.c b/util.c
new file mode 100644
index 0000000..c552a32
--- /dev/null
+++ b/util.c
@@ -0,0 +1,37 @@
+// synacor challenge (@waffle87)
+#include "util.h"
+
+#ifndef NDEBUG
+char *reg_string(unsigned short r) {
+ static char str[6];
+ switch (r) {
+ case 32768:
+ sprintf(str, "r0");
+ break;
+ case 32769:
+ sprintf(str, "r1");
+ break;
+ case 32770:
+ sprintf(str, "r2");
+ break;
+ case 32771:
+ sprintf(str, "r3");
+ break;
+ case 32772:
+ sprintf(str, "r4");
+ break;
+ case 32773:
+ sprintf(str, "r5");
+ break;
+ case 32774:
+ sprintf(str, "r6");
+ break;
+ case 32775:
+ sprintf(str, "r7");
+ break;
+ default:
+ sprintf(str, "null");
+ }
+ return str;
+}
+#endif // NDEBUG