Assembling the first yasep instructions
This commit is contained in:
parent
fa4614af23
commit
72cf6186e3
1
Makefile
1
Makefile
@ -106,6 +106,7 @@ dist:
|
|||||||
$(PACKAGE)-$(VERSION)/test/java.S \
|
$(PACKAGE)-$(VERSION)/test/java.S \
|
||||||
$(PACKAGE)-$(VERSION)/test/sparc.S \
|
$(PACKAGE)-$(VERSION)/test/sparc.S \
|
||||||
$(PACKAGE)-$(VERSION)/test/sparc64.S \
|
$(PACKAGE)-$(VERSION)/test/sparc64.S \
|
||||||
|
$(PACKAGE)-$(VERSION)/test/yasep.S \
|
||||||
$(PACKAGE)-$(VERSION)/test/Makefile \
|
$(PACKAGE)-$(VERSION)/test/Makefile \
|
||||||
$(PACKAGE)-$(VERSION)/test/project.conf \
|
$(PACKAGE)-$(VERSION)/test/project.conf \
|
||||||
$(PACKAGE)-$(VERSION)/Makefile \
|
$(PACKAGE)-$(VERSION)/Makefile \
|
||||||
|
@ -179,6 +179,8 @@ install: $(TARGETS)
|
|||||||
$(INSTALL) -m 0644 -- sparc.so $(DESTDIR)$(LIBDIR)/asm/arch/sparc.so
|
$(INSTALL) -m 0644 -- sparc.so $(DESTDIR)$(LIBDIR)/asm/arch/sparc.so
|
||||||
$(MKDIR) $(DESTDIR)$(LIBDIR)/asm/arch
|
$(MKDIR) $(DESTDIR)$(LIBDIR)/asm/arch
|
||||||
$(INSTALL) -m 0644 -- sparc64.so $(DESTDIR)$(LIBDIR)/asm/arch/sparc64.so
|
$(INSTALL) -m 0644 -- sparc64.so $(DESTDIR)$(LIBDIR)/asm/arch/sparc64.so
|
||||||
|
$(MKDIR) $(DESTDIR)$(LIBDIR)/asm/arch
|
||||||
|
$(INSTALL) -m 0644 -- yasep.so $(DESTDIR)$(LIBDIR)/asm/arch/yasep.so
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/amd64.so
|
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/amd64.so
|
||||||
@ -193,5 +195,6 @@ uninstall:
|
|||||||
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/mips.so
|
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/mips.so
|
||||||
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/sparc.so
|
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/sparc.so
|
||||||
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/sparc64.so
|
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/sparc64.so
|
||||||
|
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/yasep.so
|
||||||
|
|
||||||
.PHONY: all clean distclean install uninstall
|
.PHONY: all clean distclean install uninstall
|
||||||
|
@ -2,7 +2,7 @@ targets=amd64,arm,dalvik,i386,i386_real,i486,i586,i686,java,mips,sparc,sparc64,y
|
|||||||
cppflags_force=-I ../../include
|
cppflags_force=-I ../../include
|
||||||
cflags_force=-W `pkg-config --cflags libSystem`
|
cflags_force=-W `pkg-config --cflags libSystem`
|
||||||
cflags=-Wall -g -O2 -fPIC -pedantic
|
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,yasep.ins
|
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,yasep.reg
|
||||||
|
|
||||||
[amd64]
|
[amd64]
|
||||||
type=plugin
|
type=plugin
|
||||||
@ -103,6 +103,7 @@ depends=common.ins,null.ins,sparc.h,sparc.ins,sparc.reg
|
|||||||
[yasep]
|
[yasep]
|
||||||
type=plugin
|
type=plugin
|
||||||
sources=yasep.c
|
sources=yasep.c
|
||||||
|
install=$(LIBDIR)/asm/arch
|
||||||
|
|
||||||
[yasep.c]
|
[yasep.c]
|
||||||
depends=common.ins,null.ins,yasep.ins
|
depends=common.ins,null.ins,yasep.ins,yasep.reg
|
||||||
|
@ -22,6 +22,15 @@
|
|||||||
/* yasep */
|
/* yasep */
|
||||||
/* private */
|
/* private */
|
||||||
/* variables */
|
/* variables */
|
||||||
|
/* plug-in */
|
||||||
|
#define REG(name, size, id) { "" # name, size, id },
|
||||||
|
static ArchRegister _yasep_registers[] =
|
||||||
|
{
|
||||||
|
#include "yasep.reg"
|
||||||
|
{ NULL, 0, 0 }
|
||||||
|
};
|
||||||
|
#undef REG
|
||||||
|
|
||||||
static ArchInstruction _yasep_instructions[] =
|
static ArchInstruction _yasep_instructions[] =
|
||||||
{
|
{
|
||||||
#include "yasep.ins"
|
#include "yasep.ins"
|
||||||
@ -30,8 +39,10 @@ static ArchInstruction _yasep_instructions[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* functions */
|
/* prototypes */
|
||||||
/* plug-in */
|
/* plug-in */
|
||||||
|
static int _yasep_write(ArchPlugin * plugin, ArchInstruction * instruction,
|
||||||
|
ArchInstructionCall * call);
|
||||||
|
|
||||||
|
|
||||||
/* protected */
|
/* protected */
|
||||||
@ -41,10 +52,54 @@ ArchPlugin arch_plugin =
|
|||||||
NULL,
|
NULL,
|
||||||
"yasep",
|
"yasep",
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
_yasep_registers,
|
||||||
_yasep_instructions,
|
_yasep_instructions,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
_yasep_write,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* private */
|
||||||
|
/* functions */
|
||||||
|
/* plug-in */
|
||||||
|
/* yasep_write */
|
||||||
|
static int _write_16(ArchPlugin * plugin, ArchInstruction * instruction,
|
||||||
|
ArchInstructionCall * call);
|
||||||
|
static int _write_32(ArchPlugin * plugin, ArchInstruction * instruction,
|
||||||
|
ArchInstructionCall * call);
|
||||||
|
|
||||||
|
static int _yasep_write(ArchPlugin * plugin, ArchInstruction * instruction,
|
||||||
|
ArchInstructionCall * call)
|
||||||
|
{
|
||||||
|
return (instruction->opcode & 0x1)
|
||||||
|
? _write_32(plugin, instruction, call)
|
||||||
|
: _write_16(plugin, instruction, call);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _write_16(ArchPlugin * plugin, ArchInstruction * instruction,
|
||||||
|
ArchInstructionCall * call)
|
||||||
|
{
|
||||||
|
ArchPluginHelper * helper = plugin->helper;
|
||||||
|
uint16_t opcode = instruction->opcode;
|
||||||
|
|
||||||
|
opcode = _htob16(opcode);
|
||||||
|
if(helper->write(helper->arch, &opcode, sizeof(opcode))
|
||||||
|
!= sizeof(opcode))
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _write_32(ArchPlugin * plugin, ArchInstruction * instruction,
|
||||||
|
ArchInstructionCall * call)
|
||||||
|
{
|
||||||
|
ArchPluginHelper * helper = plugin->helper;
|
||||||
|
uint32_t opcode = instruction->opcode;
|
||||||
|
|
||||||
|
opcode = _htob32(opcode);
|
||||||
|
if(helper->write(helper->arch, &opcode, sizeof(opcode))
|
||||||
|
!= sizeof(opcode))
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
16
src/arch/yasep.reg
Normal file
16
src/arch/yasep.reg
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
REG(r0, 32, 0x00)
|
||||||
|
REG(r1, 32, 0x01)
|
||||||
|
REG(r2, 32, 0x02)
|
||||||
|
REG(r3, 32, 0x03)
|
||||||
|
REG(r4, 32, 0x04)
|
||||||
|
REG(r5, 32, 0x05)
|
||||||
|
REG(r6, 32, 0x06)
|
||||||
|
REG(r7, 32, 0x07)
|
||||||
|
REG(r8, 32, 0x08)
|
||||||
|
REG(r9, 32, 0x09)
|
||||||
|
REG(r10, 32, 0x0a)
|
||||||
|
REG(r11, 32, 0x0b)
|
||||||
|
REG(r12, 32, 0x0c)
|
||||||
|
REG(r13, 32, 0x0d)
|
||||||
|
REG(r14, 32, 0x0e)
|
||||||
|
REG(r15, 32, 0x0f)
|
@ -1,4 +1,4 @@
|
|||||||
TARGETS = amd64.o arm.o dalvik.o i386.o i386_real.o i486.o i586.o i686.o mips.o java.o sparc.o sparc64.o
|
TARGETS = amd64.o arm.o dalvik.o i386.o i386_real.o i486.o i586.o i686.o mips.o java.o sparc.o sparc64.o yasep.o
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
DESTDIR =
|
DESTDIR =
|
||||||
BINDIR = $(PREFIX)/bin
|
BINDIR = $(PREFIX)/bin
|
||||||
@ -48,6 +48,9 @@ sparc.o_ASFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(ASFLAGS) -a sparc
|
|||||||
sparc64.o_OBJS = sparc64.o
|
sparc64.o_OBJS = sparc64.o
|
||||||
sparc64.o_ASFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(ASFLAGS) -a sparc64
|
sparc64.o_ASFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(ASFLAGS) -a sparc64
|
||||||
|
|
||||||
|
yasep.o_OBJS = yasep.o
|
||||||
|
yasep.o_ASFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(ASFLAGS) -a yasep -f flat
|
||||||
|
|
||||||
amd64.o: amd64.S ../src/asm
|
amd64.o: amd64.S ../src/asm
|
||||||
$(AS) $(amd64.o_ASFLAGS) -o amd64.o amd64.S
|
$(AS) $(amd64.o_ASFLAGS) -o amd64.o amd64.S
|
||||||
|
|
||||||
@ -84,8 +87,11 @@ sparc.o: sparc.S ../src/asm
|
|||||||
sparc64.o: sparc64.S ../src/asm
|
sparc64.o: sparc64.S ../src/asm
|
||||||
$(AS) $(sparc64.o_ASFLAGS) -o sparc64.o sparc64.S
|
$(AS) $(sparc64.o_ASFLAGS) -o sparc64.o sparc64.S
|
||||||
|
|
||||||
|
yasep.o: yasep.S ../src/asm
|
||||||
|
$(AS) $(yasep.o_ASFLAGS) -o yasep.o yasep.S
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) -- $(amd64.o_OBJS) $(arm.o_OBJS) $(dalvik.o_OBJS) $(i386.o_OBJS) $(i386_real.o_OBJS) $(i486.o_OBJS) $(i586.o_OBJS) $(i686.o_OBJS) $(mips.o_OBJS) $(java.o_OBJS) $(sparc.o_OBJS) $(sparc64.o_OBJS)
|
$(RM) -- $(amd64.o_OBJS) $(arm.o_OBJS) $(dalvik.o_OBJS) $(i386.o_OBJS) $(i386_real.o_OBJS) $(i486.o_OBJS) $(i586.o_OBJS) $(i686.o_OBJS) $(mips.o_OBJS) $(java.o_OBJS) $(sparc.o_OBJS) $(sparc64.o_OBJS) $(yasep.o_OBJS)
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
$(RM) -- $(TARGETS)
|
$(RM) -- $(TARGETS)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
targets=amd64.o,arm.o,dalvik.o,i386.o,i386_real.o,i486.o,i586.o,i686.o,mips.o,java.o,sparc.o,sparc64.o
|
targets=amd64.o,arm.o,dalvik.o,i386.o,i386_real.o,i486.o,i586.o,i686.o,mips.o,java.o,sparc.o,sparc64.o,yasep.o
|
||||||
as=../src/asm-static
|
as=../src/asm-static
|
||||||
dist=Makefile
|
dist=Makefile
|
||||||
|
|
||||||
@ -97,3 +97,11 @@ sources=sparc64.S
|
|||||||
[sparc64.S]
|
[sparc64.S]
|
||||||
asflags=-a sparc64
|
asflags=-a sparc64
|
||||||
depends=../src/asm
|
depends=../src/asm
|
||||||
|
|
||||||
|
[yasep.o]
|
||||||
|
type=object
|
||||||
|
sources=yasep.S
|
||||||
|
|
||||||
|
[yasep.S]
|
||||||
|
asflags=-a yasep -f flat
|
||||||
|
depends=../src/asm
|
||||||
|
3
test/yasep.S
Normal file
3
test/yasep.S
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
.text
|
||||||
|
add %r0, %r1
|
Loading…
Reference in New Issue
Block a user