summaryrefslogtreecommitdiff
path: root/lexer/cpu
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2020-12-04 15:20:28 -0500
committermrb0nk500 <b0nk@b0nk.xyz>2020-12-04 15:20:28 -0500
commit96393257a43ac52f2b911594d106741245dec5f0 (patch)
tree6b9d11c50ed3cd1920444c4dd0ee4027814ef4bd /lexer/cpu
parent83ce1151ee1f06ae6b1c5c1018cc2489494e5ea4 (diff)
- Started work on writing the new version of the
assembler. - Did alot of stuff in the emulator. - Did alot of stuff in the SuB Suite.
Diffstat (limited to 'lexer/cpu')
-rw-r--r--lexer/cpu/sux/cpu.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/lexer/cpu/sux/cpu.c b/lexer/cpu/sux/cpu.c
new file mode 100644
index 0000000..cd6d364
--- /dev/null
+++ b/lexer/cpu/sux/cpu.c
@@ -0,0 +1,30 @@
+#include <ctype.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+static char current_ext;
+
+int is_ext(char c) {
+ return (c && c != '.' && !isspace(c));
+}
+
+void cpu_error(int code) {
+
+}
+
+char *lex_inst(char *s, int *inst_len, char **ext, int *ext_len, int *ext_count) {
+ char *inst = s;
+ int count = *ext_count;
+ for (; is_ext(*s); s++);
+ *inst_len = s - inst;
+ for (; *s++ == '.' && count < MAX_QUALIFIERS;) {
+ ext[count] = s;
+ for (; is_ext(*s); s++);
+ ext_len[count] = s - ext[count];
+ (ext_len[count] <= 0) ? (cpu_error(34)) : (count++);
+ }
+ *ext_count = count;
+ current_ext = (count > 0) ? tolower(ext[0][0]) : '\0';
+ return s;
+}