diff src/lwasm.c @ 27:f736579569b4

Added handlers for inherent and register to register instructions
author lost
date Fri, 02 Jan 2009 02:56:04 +0000
parents d2e86babd958
children 9bd0fbfe7405
line wrap: on
line diff
--- a/src/lwasm.c	Fri Jan 02 02:38:02 2009 +0000
+++ b/src/lwasm.c	Fri Jan 02 02:56:04 2009 +0000
@@ -56,3 +56,46 @@
 	
 	return r;
 }
+
+void lwasm_emit(asmstate_t *as, lwasm_line_t *l, int b)
+{
+	as -> addr += 1;
+
+	if (as -> passnum == 1)
+		return;
+
+	fprintf(stderr, "FIXME: trying to emit code in pass 2 but not implemented.\n");		
+}
+
+void lwasm_emitop(asmstate_t *as, lwasm_line_t *l, int o)
+{
+	if (o >= 0x100)
+		lwasm_emit(as, l, o >> 8);
+	lwasm_emit(as, l, o & 0xff);
+}
+
+int lwasm_lookupreg2(const char *reglist, char **str)
+{
+	int rval = 0;
+
+	while (*reglist)
+	{
+		if (toupper(**str) == *reglist)
+		{
+			// first char matches
+			if (reglist[1] == ' ' && !isalpha(*(*str + 1)))
+				break;
+			if (toupper(*(*str + 1)) == reglist[1])
+				break;
+		}
+		reglist += 2;
+		rval++;
+	}
+	if (!*reglist)
+		return -1;
+	if (reglist[1] == ' ')
+		(*str)++;
+	else
+		(*str) += 2;
+	return rval;
+}