From 6fb34179efc44a8d3d39cfa7a514ecaaed83e9f8 Mon Sep 17 00:00:00 2001 From: Jack Sangdahl <0x6A73@pm.me> Date: Mon, 1 Apr 2024 14:00:27 -0600 Subject: initial --- util.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 util.c (limited to 'util.c') 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 -- cgit v1.2.3