From fa4614af23c9121b12c94501431d98b8d9235b7e Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Wed, 28 Sep 2011 12:04:05 +0000 Subject: [PATCH] Introducing the yasep architecture --- Makefile | 2 ++ src/arch/Makefile | 14 ++++++++++-- src/arch/project.conf | 11 ++++++++-- src/arch/yasep.c | 50 +++++++++++++++++++++++++++++++++++++++++++ src/arch/yasep.ins | 40 ++++++++++++++++++++++++++++++++++ 5 files changed, 113 insertions(+), 4 deletions(-) create mode 100644 src/arch/yasep.c create mode 100644 src/arch/yasep.ins diff --git a/Makefile b/Makefile index c91bd6e..e98eddb 100644 --- a/Makefile +++ b/Makefile @@ -61,6 +61,7 @@ dist: $(PACKAGE)-$(VERSION)/src/arch/mips.c \ $(PACKAGE)-$(VERSION)/src/arch/sparc.c \ $(PACKAGE)-$(VERSION)/src/arch/sparc64.c \ + $(PACKAGE)-$(VERSION)/src/arch/yasep.c \ $(PACKAGE)-$(VERSION)/src/arch/Makefile \ $(PACKAGE)-$(VERSION)/src/arch/amd64.ins \ $(PACKAGE)-$(VERSION)/src/arch/amd64.reg \ @@ -84,6 +85,7 @@ dist: $(PACKAGE)-$(VERSION)/src/arch/sparc.h \ $(PACKAGE)-$(VERSION)/src/arch/sparc.ins \ $(PACKAGE)-$(VERSION)/src/arch/sparc.reg \ + $(PACKAGE)-$(VERSION)/src/arch/yasep.ins \ $(PACKAGE)-$(VERSION)/src/arch/project.conf \ $(PACKAGE)-$(VERSION)/src/format/dex.c \ $(PACKAGE)-$(VERSION)/src/format/elf.c \ diff --git a/src/arch/Makefile b/src/arch/Makefile index 277483b..78089bb 100644 --- a/src/arch/Makefile +++ b/src/arch/Makefile @@ -1,4 +1,4 @@ -TARGETS = amd64.so arm.so dalvik.so i386.so i386_real.so i486.so i586.so i686.so java.so mips.so sparc.so sparc64.so +TARGETS = amd64.so arm.so dalvik.so i386.so i386_real.so i486.so i586.so i686.so java.so mips.so sparc.so sparc64.so yasep.so PREFIX = /usr/local DESTDIR = LIBDIR = $(PREFIX)/lib @@ -102,6 +102,13 @@ sparc64_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) sparc64.so: $(sparc64_OBJS) $(CCSHARED) -o sparc64.so $(sparc64_OBJS) $(sparc64_LDFLAGS) +yasep_OBJS = yasep.o +yasep_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS) +yasep_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) + +yasep.so: $(yasep_OBJS) + $(CCSHARED) -o yasep.so $(yasep_OBJS) $(yasep_LDFLAGS) + amd64.o: amd64.c amd64.ins amd64.reg common.ins null.ins i386.h i386.ins i386.reg i486.ins i686.ins i686.reg $(CC) $(amd64_CFLAGS) -c amd64.c @@ -138,8 +145,11 @@ sparc.o: sparc.c common.ins null.ins sparc.h sparc.ins sparc.reg sparc64.o: sparc64.c common.ins null.ins sparc.h sparc.ins sparc.reg $(CC) $(sparc64_CFLAGS) -c sparc64.c +yasep.o: yasep.c common.ins null.ins yasep.ins + $(CC) $(yasep_CFLAGS) -c yasep.c + clean: - $(RM) -- $(amd64_OBJS) $(arm_OBJS) $(dalvik_OBJS) $(i386_OBJS) $(i386_real_OBJS) $(i486_OBJS) $(i586_OBJS) $(i686_OBJS) $(java_OBJS) $(mips_OBJS) $(sparc_OBJS) $(sparc64_OBJS) + $(RM) -- $(amd64_OBJS) $(arm_OBJS) $(dalvik_OBJS) $(i386_OBJS) $(i386_real_OBJS) $(i486_OBJS) $(i586_OBJS) $(i686_OBJS) $(java_OBJS) $(mips_OBJS) $(sparc_OBJS) $(sparc64_OBJS) $(yasep_OBJS) distclean: clean $(RM) -- $(TARGETS) diff --git a/src/arch/project.conf b/src/arch/project.conf index 44a072e..3ffd5ef 100644 --- a/src/arch/project.conf +++ b/src/arch/project.conf @@ -1,8 +1,8 @@ -targets=amd64,arm,dalvik,i386,i386_real,i486,i586,i686,java,mips,sparc,sparc64 +targets=amd64,arm,dalvik,i386,i386_real,i486,i586,i686,java,mips,sparc,sparc64,yasep cppflags_force=-I ../../include cflags_force=-W `pkg-config --cflags libSystem` cflags=-Wall -g -O2 -fPIC -pedantic -dist=Makefile,amd64.ins,amd64.reg,arm.h,arm.ins,arm.reg,common.ins,dalvik.ins,dalvik.reg,i386.h,i386.ins,i386.reg,i486.ins,i586.ins,i686.ins,i686.reg,mips.h,mips.ins,mips.reg,null.ins,sparc.h,sparc.ins,sparc.reg +dist=Makefile,amd64.ins,amd64.reg,arm.h,arm.ins,arm.reg,common.ins,dalvik.ins,dalvik.reg,i386.h,i386.ins,i386.reg,i486.ins,i586.ins,i686.ins,i686.reg,mips.h,mips.ins,mips.reg,null.ins,sparc.h,sparc.ins,sparc.reg,yasep.ins [amd64] type=plugin @@ -99,3 +99,10 @@ install=$(LIBDIR)/asm/arch [sparc64.c] depends=common.ins,null.ins,sparc.h,sparc.ins,sparc.reg + +[yasep] +type=plugin +sources=yasep.c + +[yasep.c] +depends=common.ins,null.ins,yasep.ins diff --git a/src/arch/yasep.c b/src/arch/yasep.c new file mode 100644 index 0000000..8bd97d1 --- /dev/null +++ b/src/arch/yasep.c @@ -0,0 +1,50 @@ +/* $Id$ */ +/* Copyright (c) 2011 Pierre Pronchery */ +/* This file is part of DeforaOS Devel asm */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + + + +#include +#include "Asm.h" + + +/* yasep */ +/* private */ +/* variables */ +static ArchInstruction _yasep_instructions[] = +{ +#include "yasep.ins" +#include "common.ins" +#include "null.ins" +}; + + +/* functions */ +/* plug-in */ + + +/* protected */ +/* variables */ +ArchPlugin arch_plugin = +{ + NULL, + "yasep", + NULL, + NULL, + _yasep_instructions, + NULL, + NULL, + NULL, + NULL +}; diff --git a/src/arch/yasep.ins b/src/arch/yasep.ins new file mode 100644 index 0000000..8930a80 --- /dev/null +++ b/src/arch/yasep.ins @@ -0,0 +1,40 @@ +/* $Id$ */ +/* Copyright (c) 2011 Pierre Pronchery */ +/* This file is part of DeforaOS Devel asm */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + + + +/* generic */ +/* opcode */ +#define OPIR(opcode) (opcode << 2) +#define OPRR(opcode) ((opcode << 2) | 0x2) +#define OPIRL(opcode) ((opcode << 2) | 0x1) +#define OPRRL(opcode) ((opcode << 2) | 0x3) +/* flags */ +#define OPIRF (16 << AOD_SIZE) +#define OPRRF (16 << AOD_SIZE) +#define OPIRLF (32 << AOD_SIZE) +#define OPRRLF (32 << AOD_SIZE) +/* operands */ +#define OP_DST3 AO_REGISTER(0, 32, 0) +#define OP_IMM4 AO_IMMEDIATE(0, 4, 0) +#define OP_IMM16 AO_IMMEDIATE(0, 16, 0) +#define OP_SI4 AO_REGISTER(0, 32, 0) +#define OP_SND AO_REGISTER(0, 32, 0) + +/* instructions */ +{ "add", OPIR(0x0c), OPIRF, AO_2(OP_IMM4, OP_SND) }, +{ "add", OPRR(0x0c), OPRRF, AO_2(OP_SI4, OP_SND) }, +{ "add", OPIRL(0x0c),OPIRLF, AO_2(OP_SI4, OP_IMM16) }, +{ "add", OPRRL(0x0c),OPRRLF, AO_3(OP_SND, OP_SI4, OP_DST3) },