Importing support for yasep16
This commit is contained in:
parent
0ab47975aa
commit
3207b9e855
2
Makefile
2
Makefile
@ -71,6 +71,7 @@ dist:
|
||||
$(PACKAGE)-$(VERSION)/src/arch/sparc.c \
|
||||
$(PACKAGE)-$(VERSION)/src/arch/sparc64.c \
|
||||
$(PACKAGE)-$(VERSION)/src/arch/yasep.c \
|
||||
$(PACKAGE)-$(VERSION)/src/arch/yasep16.c \
|
||||
$(PACKAGE)-$(VERSION)/src/arch/Makefile \
|
||||
$(PACKAGE)-$(VERSION)/src/arch/amd64.ins \
|
||||
$(PACKAGE)-$(VERSION)/src/arch/amd64.reg \
|
||||
@ -121,6 +122,7 @@ dist:
|
||||
$(PACKAGE)-$(VERSION)/test/sparc.S \
|
||||
$(PACKAGE)-$(VERSION)/test/sparc64.S \
|
||||
$(PACKAGE)-$(VERSION)/test/yasep.S \
|
||||
$(PACKAGE)-$(VERSION)/test/yasep16.S \
|
||||
$(PACKAGE)-$(VERSION)/test/Makefile \
|
||||
$(PACKAGE)-$(VERSION)/test/project.conf \
|
||||
$(PACKAGE)-$(VERSION)/Makefile \
|
||||
|
@ -1,4 +1,4 @@
|
||||
TARGETS = amd64.so arm.so armeb.so armel.so dalvik.so i386.so i386_real.so i486.so i586.so i686.so java.so mips.so mipseb.so mipsel.so sparc.so sparc64.so yasep.so
|
||||
TARGETS = amd64.so arm.so armeb.so armel.so dalvik.so i386.so i386_real.so i486.so i586.so i686.so java.so mips.so mipseb.so mipsel.so sparc.so sparc64.so yasep.so yasep16.so
|
||||
PREFIX = /usr/local
|
||||
DESTDIR =
|
||||
LIBDIR = $(PREFIX)/lib
|
||||
@ -137,6 +137,13 @@ yasep_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
||||
yasep.so: $(yasep_OBJS)
|
||||
$(CCSHARED) -o yasep.so $(yasep_OBJS) $(yasep_LDFLAGS)
|
||||
|
||||
yasep16_OBJS = yasep16.o
|
||||
yasep16_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
||||
yasep16_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
||||
|
||||
yasep16.so: $(yasep16_OBJS)
|
||||
$(CCSHARED) -o yasep16.so $(yasep16_OBJS) $(yasep16_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
|
||||
|
||||
@ -188,8 +195,11 @@ sparc64.o: sparc64.c common.ins null.ins sparc.h sparc.ins sparc.reg
|
||||
yasep.o: yasep.c common.ins null.ins yasep.ins yasep.reg
|
||||
$(CC) $(yasep_CFLAGS) -c yasep.c
|
||||
|
||||
yasep16.o: yasep16.c common.ins null.ins yasep.ins yasep.reg
|
||||
$(CC) $(yasep16_CFLAGS) -c yasep16.c
|
||||
|
||||
clean:
|
||||
$(RM) -- $(amd64_OBJS) $(arm_OBJS) $(armeb_OBJS) $(armel_OBJS) $(dalvik_OBJS) $(i386_OBJS) $(i386_real_OBJS) $(i486_OBJS) $(i586_OBJS) $(i686_OBJS) $(java_OBJS) $(mips_OBJS) $(mipseb_OBJS) $(mipsel_OBJS) $(sparc_OBJS) $(sparc64_OBJS) $(yasep_OBJS)
|
||||
$(RM) -- $(amd64_OBJS) $(arm_OBJS) $(armeb_OBJS) $(armel_OBJS) $(dalvik_OBJS) $(i386_OBJS) $(i386_real_OBJS) $(i486_OBJS) $(i586_OBJS) $(i686_OBJS) $(java_OBJS) $(mips_OBJS) $(mipseb_OBJS) $(mipsel_OBJS) $(sparc_OBJS) $(sparc64_OBJS) $(yasep_OBJS) $(yasep16_OBJS)
|
||||
|
||||
distclean: clean
|
||||
$(RM) -- $(TARGETS)
|
||||
@ -229,6 +239,8 @@ install: $(TARGETS)
|
||||
$(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
|
||||
$(MKDIR) $(DESTDIR)$(LIBDIR)/asm/arch
|
||||
$(INSTALL) -m 0644 -- yasep16.so $(DESTDIR)$(LIBDIR)/asm/arch/yasep16.so
|
||||
|
||||
uninstall:
|
||||
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/amd64.so
|
||||
@ -248,5 +260,6 @@ uninstall:
|
||||
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/sparc.so
|
||||
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/sparc64.so
|
||||
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/yasep.so
|
||||
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/yasep16.so
|
||||
|
||||
.PHONY: all clean distclean install uninstall
|
||||
|
@ -1,4 +1,4 @@
|
||||
targets=amd64,arm,armeb,armel,dalvik,i386,i386_real,i486,i586,i686,java,mips,mipseb,mipsel,sparc,sparc64,yasep
|
||||
targets=amd64,arm,armeb,armel,dalvik,i386,i386_real,i486,i586,i686,java,mips,mipseb,mipsel,sparc,sparc64,yasep,yasep16
|
||||
cppflags_force=-I ../../include
|
||||
cflags_force=-W `pkg-config --cflags libSystem`
|
||||
cflags=-Wall -g -O2 -fPIC -pedantic
|
||||
@ -139,3 +139,11 @@ install=$(LIBDIR)/asm/arch
|
||||
|
||||
[yasep.c]
|
||||
depends=common.ins,null.ins,yasep.ins,yasep.reg
|
||||
|
||||
[yasep16]
|
||||
type=plugin
|
||||
sources=yasep16.c
|
||||
install=$(LIBDIR)/asm/arch
|
||||
|
||||
[yasep16.c]
|
||||
depends=common.ins,null.ins,yasep.ins,yasep.reg
|
||||
|
@ -17,13 +17,22 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include "Asm.h"
|
||||
#define ARCH_yasep32
|
||||
#ifndef ARCH_yasep
|
||||
# define ARCH_yasep 32
|
||||
# define ARCH_yasep32
|
||||
# define _yasep_name "yasep"
|
||||
#endif
|
||||
|
||||
|
||||
/* yasep */
|
||||
/* private */
|
||||
/* variables */
|
||||
/* plug-in */
|
||||
static ArchDescription _yasep_description =
|
||||
{
|
||||
"flat", ARCH_ENDIAN_LITTLE, 32, 16, 0
|
||||
};
|
||||
|
||||
#define REG(name, size, id) { "" # name, size, id },
|
||||
static ArchRegister _yasep_registers[] =
|
||||
{
|
||||
@ -47,13 +56,13 @@ static int _yasep_encode(ArchPlugin * plugin, ArchInstruction * instruction,
|
||||
static int _yasep_decode(ArchPlugin * plugin, ArchInstructionCall * call);
|
||||
|
||||
|
||||
/* protected */
|
||||
/* public */
|
||||
/* variables */
|
||||
ArchPlugin arch_plugin =
|
||||
{
|
||||
NULL,
|
||||
"yasep",
|
||||
NULL,
|
||||
_yasep_name,
|
||||
&_yasep_description,
|
||||
_yasep_registers,
|
||||
_yasep_instructions,
|
||||
NULL,
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2011 Yann Guidon <yg@ygdes.org> */
|
||||
/* 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
|
||||
|
21
src/arch/yasep16.c
Normal file
21
src/arch/yasep16.c
Normal file
@ -0,0 +1,21 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
|
||||
/* 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 <http://www.gnu.org/licenses/>. */
|
||||
|
||||
|
||||
|
||||
#define ARCH_yasep 16
|
||||
#define ARCH_yasep16
|
||||
#define _yasep_name "yasep16"
|
||||
#include "yasep.c"
|
44
src/parser.c
44
src/parser.c
@ -40,12 +40,12 @@ typedef struct _State
|
||||
|
||||
|
||||
/* prototypes */
|
||||
static int _parser_scan(State * state);
|
||||
static int _parser_check(State * state, TokenCode code);
|
||||
static int _parser_defines(State * state, AsmPrefs * ap);
|
||||
static int _parser_error(State * state, char const * format, ...);
|
||||
static int _parser_is_code(State * state, TokenCode code);
|
||||
static int _parser_in_set(State * state, TokenSet set);
|
||||
|
||||
static int _parser_error(State * state, char const * format, ...);
|
||||
static int _parser_scan(State * state);
|
||||
static int _parser_warning(State * state, char const * format, ...);
|
||||
|
||||
/* grammar */
|
||||
@ -132,6 +132,31 @@ static int _parser_check(State * state, TokenCode code)
|
||||
}
|
||||
|
||||
|
||||
/* parser_defines */
|
||||
static int _parser_defines(State * state, AsmPrefs * ap)
|
||||
{
|
||||
int ret = 0;
|
||||
char const * p;
|
||||
char * q;
|
||||
size_t len;
|
||||
size_t i;
|
||||
|
||||
if((p = asmcode_get_arch(state->code)) != NULL
|
||||
&& (len = strlen(p)) > 0)
|
||||
{
|
||||
if((q = malloc(len + 5)) == NULL)
|
||||
return -error_set_code(1, "%s", strerror(errno));
|
||||
snprintf(q, len + 5, "__%s__", p);
|
||||
ret |= cpp_define_add(state->cpp, q, NULL);
|
||||
free(q);
|
||||
}
|
||||
if(ret == 0 && ap != NULL)
|
||||
for(i = 0; i < ap->defines_cnt; i++)
|
||||
ret |= cpp_define_add(state->cpp, ap->defines[i], NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* parser_is_code */
|
||||
static int _parser_is_code(State * state, TokenCode code)
|
||||
{
|
||||
@ -193,7 +218,6 @@ int parser(AsmPrefs * ap, AsmCode * code, char const * infile)
|
||||
{
|
||||
CppPrefs prefs;
|
||||
State state;
|
||||
size_t i;
|
||||
|
||||
memset(&prefs, 0, sizeof(prefs));
|
||||
prefs.filename = infile;
|
||||
@ -202,12 +226,16 @@ int parser(AsmPrefs * ap, AsmCode * code, char const * infile)
|
||||
state.code = code;
|
||||
if((state.cpp = cpp_new(&prefs)) == NULL)
|
||||
return -1;
|
||||
if(ap != NULL)
|
||||
for(i = 0; i < ap->defines_cnt; i++)
|
||||
/* FIXME check errors */
|
||||
cpp_define_add(state.cpp, ap->defines[i], NULL);
|
||||
if(_parser_defines(&state, ap) != 0)
|
||||
{
|
||||
cpp_delete(state.cpp);
|
||||
return -1;
|
||||
}
|
||||
if(_parser_scan(&state) != 0)
|
||||
{
|
||||
cpp_delete(state.cpp);
|
||||
return _parser_error(&state, "%s", error_get());
|
||||
}
|
||||
if(_program(&state) != 0)
|
||||
error_set_code(1, "%s%s%u%s%u%s", infile,
|
||||
": Compilation failed with ", state.error_cnt,
|
||||
|
@ -1,4 +1,4 @@
|
||||
TARGETS = amd64.o arm.o armeb.o armel.o dalvik.o i386.o i386_real.o i486.o i586.o i686.o mips.o mipseb.o mipsel.o java.o sparc.o sparc64.o yasep.o
|
||||
TARGETS = amd64.o arm.o armeb.o armel.o dalvik.o i386.o i386_real.o i486.o i586.o i686.o mips.o mipseb.o mipsel.o java.o sparc.o sparc64.o yasep.o yasep16.o
|
||||
PREFIX = /usr/local
|
||||
DESTDIR =
|
||||
BINDIR = $(PREFIX)/bin
|
||||
@ -63,6 +63,9 @@ sparc64.o_ASFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(ASFLAGS) -a sparc64
|
||||
yasep.o_OBJS = yasep.o
|
||||
yasep.o_ASFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(ASFLAGS) -a yasep -f flat
|
||||
|
||||
yasep16.o_OBJS = yasep16.o
|
||||
yasep16.o_ASFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(ASFLAGS) -a yasep16 -f flat
|
||||
|
||||
amd64.o: amd64.S ../src/asm
|
||||
$(AS) $(amd64.o_ASFLAGS) -o amd64.o amd64.S
|
||||
|
||||
@ -114,8 +117,11 @@ sparc64.o: sparc64.S ../src/asm
|
||||
yasep.o: yasep.S ../src/asm
|
||||
$(AS) $(yasep.o_ASFLAGS) -o yasep.o yasep.S
|
||||
|
||||
yasep16.o: yasep16.S ../src/asm yasep.S
|
||||
$(AS) $(yasep16.o_ASFLAGS) -o yasep16.o yasep16.S
|
||||
|
||||
clean:
|
||||
$(RM) -- $(amd64.o_OBJS) $(arm.o_OBJS) $(armeb.o_OBJS) $(armel.o_OBJS) $(dalvik.o_OBJS) $(i386.o_OBJS) $(i386_real.o_OBJS) $(i486.o_OBJS) $(i586.o_OBJS) $(i686.o_OBJS) $(mips.o_OBJS) $(mipseb.o_OBJS) $(mipsel.o_OBJS) $(java.o_OBJS) $(sparc.o_OBJS) $(sparc64.o_OBJS) $(yasep.o_OBJS)
|
||||
$(RM) -- $(amd64.o_OBJS) $(arm.o_OBJS) $(armeb.o_OBJS) $(armel.o_OBJS) $(dalvik.o_OBJS) $(i386.o_OBJS) $(i386_real.o_OBJS) $(i486.o_OBJS) $(i586.o_OBJS) $(i686.o_OBJS) $(mips.o_OBJS) $(mipseb.o_OBJS) $(mipsel.o_OBJS) $(java.o_OBJS) $(sparc.o_OBJS) $(sparc64.o_OBJS) $(yasep.o_OBJS) $(yasep16.o_OBJS)
|
||||
|
||||
distclean: clean
|
||||
$(RM) -- $(TARGETS)
|
||||
|
@ -1,4 +1,4 @@
|
||||
targets=amd64.o,arm.o,armeb.o,armel.o,dalvik.o,i386.o,i386_real.o,i486.o,i586.o,i686.o,mips.o,mipseb.o,mipsel.o,java.o,sparc.o,sparc64.o,yasep.o
|
||||
targets=amd64.o,arm.o,armeb.o,armel.o,dalvik.o,i386.o,i386_real.o,i486.o,i586.o,i686.o,mips.o,mipseb.o,mipsel.o,java.o,sparc.o,sparc64.o,yasep.o,yasep16.o
|
||||
as=../src/asm-static
|
||||
dist=Makefile
|
||||
|
||||
@ -137,3 +137,11 @@ sources=yasep.S
|
||||
[yasep.S]
|
||||
asflags=-a yasep -f flat
|
||||
depends=../src/asm
|
||||
|
||||
[yasep16.o]
|
||||
type=object
|
||||
sources=yasep16.S
|
||||
|
||||
[yasep16.S]
|
||||
asflags=-a yasep16 -f flat
|
||||
depends=../src/asm,yasep.S
|
||||
|
@ -13,9 +13,13 @@
|
||||
get $0x09, %r1
|
||||
get %r10, %r11
|
||||
lsb %r12, %r13
|
||||
#ifdef __yasep__
|
||||
lsh %r14, %r15
|
||||
#endif
|
||||
lzb %npc, %d5
|
||||
#ifdef __yasep__
|
||||
lzh %a5, %d4
|
||||
#endif
|
||||
mov $0x04, %a4
|
||||
mov %d3, %a3
|
||||
mul8h $0x03, %d2
|
||||
@ -41,10 +45,12 @@
|
||||
sar %r0, %r1
|
||||
sb $0x08, %r1
|
||||
sb %r0, %r1
|
||||
#ifdef __yasep__
|
||||
sh $0x09, %r1
|
||||
sh %r0, %r1
|
||||
shh $0x0a, %r1
|
||||
shh %r0, %r1
|
||||
#endif
|
||||
shl $0x0b, %r1
|
||||
shl %r0, %r1
|
||||
shr $0x0c, %r1
|
||||
|
2
test/yasep16.S
Normal file
2
test/yasep16.S
Normal file
@ -0,0 +1,2 @@
|
||||
/* $Id$ */
|
||||
#include "yasep.S"
|
Loading…
Reference in New Issue
Block a user