diff src/lwasm.c @ 32:9bd0fbfe7405

Added basic indexed mode handling
author lost
date Fri, 02 Jan 2009 04:22:39 +0000
parents f736579569b4
children 538e15927776
line wrap: on
line diff
--- a/src/lwasm.c	Fri Jan 02 03:35:29 2009 +0000
+++ b/src/lwasm.c	Fri Jan 02 04:22:39 2009 +0000
@@ -99,3 +99,51 @@
 		(*str) += 2;
 	return rval;
 }
+
+int lwasm_lookupreg3(const char *rlist, const char **str)
+{
+	int rval = 0;
+	int f = 0;
+	const char *reglist = rlist;
+		
+	while (*reglist)
+	{
+		if (toupper(**str) == *reglist)
+		{
+			// first char matches
+			if (reglist[1] == ' ')
+			{
+				f = 1;
+				break;
+			}
+			if (toupper(*(*str + 1)) == reglist[1])
+			{
+				// second char matches
+				if (reglist[2] == ' ')
+				{
+					f = 1;
+					break;
+				}
+				if (toupper(*(*str + 2)) == reglist[2])
+				{
+					f = 1;
+					break;
+				}
+			}
+		}
+		reglist += 3;
+		rval++;
+	}
+	if (f == 0)
+		return -1;
+	
+	
+	reglist = rval * 3 + rlist;
+	if (reglist[1] == ' ')
+		(*str) += 1;
+	else if (reglist[2] == ' ')
+		(*str) += 2;
+	else
+		(*str)+=3;
+	return rval;
+}