changeset 30:7c6b8bdf8c5c

Added handler for TFM instructions
author lost
date Fri, 02 Jan 2009 03:35:18 +0000
parents 37aec845aef3
children 674ee393426c
files src/Makefile.am src/insn_misc.c
diffstat 2 files changed, 1 insertions(+), 114 deletions(-) [+]
line wrap: on
line diff
--- a/src/Makefile.am	Fri Jan 02 03:27:33 2009 +0000
+++ b/src/Makefile.am	Fri Jan 02 03:35:18 2009 +0000
@@ -1,3 +1,3 @@
 bin_PROGRAMS = lwasm
-lwasm_SOURCES = main.c expr.c pass1.c pass2.c util.c instab.c parse.c lwasm.c insn_inh.c insn_rtor.c insn_rlist.c insn_rel.c
+lwasm_SOURCES = main.c expr.c pass1.c pass2.c util.c instab.c parse.c lwasm.c insn_inh.c insn_rtor.c insn_rlist.c insn_rel.c insn_tfm.c
 EXTRA_DIST = instab.h lwasm.h expr.h util.h
--- a/src/insn_misc.c	Fri Jan 02 03:27:33 2009 +0000
+++ b/src/insn_misc.c	Fri Jan 02 03:35:18 2009 +0000
@@ -74,88 +74,6 @@
 	}
 }
 
-void insn_tfm(asmstate_t *as, sourceline_t *cl, char **optr)
-{
-	static const char *reglist = "DXYUS   AB  00EF";
-	int r0, r1;
-	char *c;
-	int tfm = 0;
-			
-	cl -> addrmode = OPER_TFM;
-			
-	c = strchr(reglist, toupper(*(*optr)++));
-	if (!c)
-	{
-		errorp1(ERR_BADOPER);
-		return;
-	}
-	r0 = c - reglist;
-	if (**optr == '+')
-	{
-		(*optr)++;
-		tfm = 1;
-	}
-	else if (**optr == '-')
-	{
-		(*optr)++;
-		tfm = 2;
-	}
-	if (*(*optr)++ != ',')
-	{
-		errorp1(ERR_BADOPER);
-		return;
-	}
-	c = strchr(reglist, toupper(*(*optr)++));
-	if (!c)
-	{
-		errorp1(ERR_BADOPER);
-		return;
-	}
-	r1 = c - reglist;
-
-	if (**optr == '+')
-	{
-		(*optr)++;
-		tfm |= 4;
-	}
-	else if (**optr == '-')
-	{
-		(*optr)++;
-		tfm |= 8;
-	}
-	
-	if (**optr && !isspace(**optr))
-	{
-		errorp1(ERR_BADOPER);
-		return;
-	}
-			
-	// valid values of tfm here are:
-	// 1: r0+,r1 (2)
-	// 4: r0,r1+ (3)
-	// 5: r0+,r1+ (0)
-	// 10: r0-,r1- (1)
-	switch (tfm)
-	{
-	case 5: //r0+,r1+
-		emitop(instab[cl -> opcode].ops[0]);
-		break;
-	case 10: //r0-,r1-
-		emitop(instab[cl -> opcode].ops[1]);
-		break;
-	case 1: // r0+,r1
-		emitop(instab[cl -> opcode].ops[2]);
-		break;
-	case 4: // r0,r1+
-		emitop(instab[cl -> opcode].ops[3]);
-		break;
-	default:
-		errorp1(ERR_BADOPER);
-		return;
-	}
-	emit((r0 << 4) | r1);
-}
-
 void insn_bitbit(asmstate_t *as, sourceline_t *cl, char **optr)
 {
 	int r;
@@ -225,34 +143,3 @@
 		errorp2(ERR_OVERFLOW);
 	emit(tv & 0xff);
 }
-
-void insn_rel8(asmstate_t *as, sourceline_t *cl, char **optr)
-{
-	int v1, rval;
-	
-	emitop(instab[cl -> opcode].ops[0]);
-	cl -> addrmode = OPER_REL8;
-	rval = eval_expr(as, cl, optr, &v1);
-	v1 &= 0xFFFF;
-	v1 -= cl -> addr + 2;
-	if (v1 < -128 || v1 > 127)
-		errorp2(ERR_OVERFLOW);
-	v1 &= 0xFFFF;
-	emit(v1 & 0xff);
-}
-
-void insn_rel16(asmstate_t *as, sourceline_t *cl, char **optr)
-{
-	int v1, rval;
-
-	emitop(instab[cl -> opcode].ops[0]);
-	cl -> addrmode = OPER_REL16;
-	rval = eval_expr(as, cl, optr, &v1);
-	v1 &= 0xFFFF;
-	v1 -= cl -> addr + 3;
-	if (instab[cl -> opcode].ops[0] > 0xff)
-		v1 -= 1;
-	v1 &= 0xFFFF;
-	emit(v1 >> 8);
-	emit(v1 & 0xff);
-}