Introducing the i386 plug-in again
This commit is contained in:
parent
e45eb58cff
commit
dcb9ea2e6f
5
Makefile
5
Makefile
@ -49,10 +49,12 @@ dist:
|
|||||||
$(PACKAGE)-$(VERSION)/src/parser.h \
|
$(PACKAGE)-$(VERSION)/src/parser.h \
|
||||||
$(PACKAGE)-$(VERSION)/src/token.h \
|
$(PACKAGE)-$(VERSION)/src/token.h \
|
||||||
$(PACKAGE)-$(VERSION)/src/project.conf \
|
$(PACKAGE)-$(VERSION)/src/project.conf \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/arch/i386.c \
|
||||||
$(PACKAGE)-$(VERSION)/src/arch/sparc.c \
|
$(PACKAGE)-$(VERSION)/src/arch/sparc.c \
|
||||||
$(PACKAGE)-$(VERSION)/src/arch/Makefile \
|
$(PACKAGE)-$(VERSION)/src/arch/Makefile \
|
||||||
$(PACKAGE)-$(VERSION)/src/arch/common.ins \
|
$(PACKAGE)-$(VERSION)/src/arch/common.ins \
|
||||||
$(PACKAGE)-$(VERSION)/src/arch/common.reg \
|
$(PACKAGE)-$(VERSION)/src/arch/i386.ins \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/arch/i386.reg \
|
||||||
$(PACKAGE)-$(VERSION)/src/arch/null.ins \
|
$(PACKAGE)-$(VERSION)/src/arch/null.ins \
|
||||||
$(PACKAGE)-$(VERSION)/src/arch/sparc.ins \
|
$(PACKAGE)-$(VERSION)/src/arch/sparc.ins \
|
||||||
$(PACKAGE)-$(VERSION)/src/arch/sparc.reg \
|
$(PACKAGE)-$(VERSION)/src/arch/sparc.reg \
|
||||||
@ -64,6 +66,7 @@ dist:
|
|||||||
$(PACKAGE)-$(VERSION)/src/format/pe.c \
|
$(PACKAGE)-$(VERSION)/src/format/pe.c \
|
||||||
$(PACKAGE)-$(VERSION)/src/format/Makefile \
|
$(PACKAGE)-$(VERSION)/src/format/Makefile \
|
||||||
$(PACKAGE)-$(VERSION)/src/format/project.conf \
|
$(PACKAGE)-$(VERSION)/src/format/project.conf \
|
||||||
|
$(PACKAGE)-$(VERSION)/test/i386.S \
|
||||||
$(PACKAGE)-$(VERSION)/test/sparc.S \
|
$(PACKAGE)-$(VERSION)/test/sparc.S \
|
||||||
$(PACKAGE)-$(VERSION)/test/Makefile \
|
$(PACKAGE)-$(VERSION)/test/Makefile \
|
||||||
$(PACKAGE)-$(VERSION)/test/project.conf \
|
$(PACKAGE)-$(VERSION)/test/project.conf \
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
TARGETS = sparc.so
|
TARGETS = i386.so sparc.so
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
DESTDIR =
|
DESTDIR =
|
||||||
LIBDIR = $(PREFIX)/lib
|
LIBDIR = $(PREFIX)/lib
|
||||||
@ -18,6 +18,13 @@ INSTALL = install
|
|||||||
|
|
||||||
all: $(TARGETS)
|
all: $(TARGETS)
|
||||||
|
|
||||||
|
i386_OBJS = i386.o
|
||||||
|
i386_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
||||||
|
i386_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
||||||
|
|
||||||
|
i386.so: $(i386_OBJS)
|
||||||
|
$(LD) -o i386.so $(i386_OBJS) $(i386_LDFLAGS)
|
||||||
|
|
||||||
sparc_OBJS = sparc.o
|
sparc_OBJS = sparc.o
|
||||||
sparc_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
sparc_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
||||||
sparc_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
sparc_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
||||||
@ -25,20 +32,26 @@ sparc_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
|||||||
sparc.so: $(sparc_OBJS)
|
sparc.so: $(sparc_OBJS)
|
||||||
$(LD) -o sparc.so $(sparc_OBJS) $(sparc_LDFLAGS)
|
$(LD) -o sparc.so $(sparc_OBJS) $(sparc_LDFLAGS)
|
||||||
|
|
||||||
sparc.o: sparc.c common.ins common.reg null.ins sparc.ins sparc.reg
|
i386.o: i386.c common.ins null.ins i386.ins i386.reg
|
||||||
|
$(CC) $(i386_CFLAGS) -c i386.c
|
||||||
|
|
||||||
|
sparc.o: sparc.c common.ins null.ins sparc.ins sparc.reg
|
||||||
$(CC) $(sparc_CFLAGS) -c sparc.c
|
$(CC) $(sparc_CFLAGS) -c sparc.c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) -- $(sparc_OBJS)
|
$(RM) -- $(i386_OBJS) $(sparc_OBJS)
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
$(RM) -- $(TARGETS)
|
$(RM) -- $(TARGETS)
|
||||||
|
|
||||||
install: $(TARGETS)
|
install: $(TARGETS)
|
||||||
|
$(MKDIR) $(DESTDIR)$(LIBDIR)/asm/arch
|
||||||
|
$(INSTALL) -m 0644 -- i386.so $(DESTDIR)$(LIBDIR)/asm/arch/i386.so
|
||||||
$(MKDIR) $(DESTDIR)$(LIBDIR)/asm/arch
|
$(MKDIR) $(DESTDIR)$(LIBDIR)/asm/arch
|
||||||
$(INSTALL) -m 0644 -- sparc.so $(DESTDIR)$(LIBDIR)/asm/arch/sparc.so
|
$(INSTALL) -m 0644 -- sparc.so $(DESTDIR)$(LIBDIR)/asm/arch/sparc.so
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
|
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/i386.so
|
||||||
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/sparc.so
|
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/sparc.so
|
||||||
|
|
||||||
.PHONY: all clean distclean install uninstall
|
.PHONY: all clean distclean install uninstall
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
AO_NONE = _AO_NONE,
|
|
||||||
AO_OP = _AO_OP,
|
|
||||||
AO_IMM = _AO_IMM,
|
|
||||||
AO_REG = _AO_REG,
|
|
||||||
AO_DREG = _AO_DREG,
|
|
||||||
AO_OP_ = _AO_OP_,
|
|
||||||
AO_IMM_ = _AO_IMM_,
|
|
||||||
AO_REG_ = _AO_REG_,
|
|
||||||
AO_DREG_= _AO_DREG_,
|
|
||||||
AO_OP__ = _AO_OP__,
|
|
||||||
AO_IMM__= _AO_IMM__,
|
|
||||||
AO_REG__= _AO_REG__,
|
|
||||||
AO_DREG__= _AO_DREG__,
|
|
47
src/arch/i386.c
Normal file
47
src/arch/i386.c
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/* $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/>. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include "Asm/arch.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* i386 */
|
||||||
|
/* private */
|
||||||
|
/* variables */
|
||||||
|
#define REG(name, size, id) { "" # name, size, id },
|
||||||
|
static ArchRegister _i386_registers[] =
|
||||||
|
{
|
||||||
|
#include "i386.reg"
|
||||||
|
{ NULL, 0, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
static ArchInstruction _i386_instructions[] =
|
||||||
|
{
|
||||||
|
#include "i386.ins"
|
||||||
|
#include "common.ins"
|
||||||
|
#include "null.ins"
|
||||||
|
};
|
||||||
|
|
||||||
|
ArchPlugin arch_plugin =
|
||||||
|
{
|
||||||
|
"i386",
|
||||||
|
"elf",
|
||||||
|
NULL,
|
||||||
|
_i386_registers,
|
||||||
|
_i386_instructions,
|
||||||
|
NULL
|
||||||
|
};
|
4
src/arch/i386.ins
Normal file
4
src/arch/i386.ins
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
/* helpers */
|
||||||
|
#define OP1F (1 << AOD_SIZE)
|
||||||
|
|
||||||
|
{ "nop", 0x90, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
|
40
src/arch/i386.reg
Normal file
40
src/arch/i386.reg
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
REG(ax, 16, 0x00)
|
||||||
|
REG(ah, 8, 0x01)
|
||||||
|
REG(al, 8, 0x02)
|
||||||
|
REG(bx, 16, 0x03)
|
||||||
|
REG(bh, 8, 0x04)
|
||||||
|
REG(bl, 8, 0x05)
|
||||||
|
REG(cx, 16, 0x06)
|
||||||
|
REG(ch, 8, 0x07)
|
||||||
|
REG(cl, 8, 0x08)
|
||||||
|
REG(dx, 16, 0x09)
|
||||||
|
REG(dh, 8, 0x0a)
|
||||||
|
REG(dl, 8, 0x0b)
|
||||||
|
REG(sp, 16, 0x0c)
|
||||||
|
REG(bp, 16, 0x0d)
|
||||||
|
REG(si, 16, 0x0e)
|
||||||
|
REG(di, 16, 0x0f)
|
||||||
|
REG(cs, 16, 0x10)
|
||||||
|
REG(ss, 16, 0x11)
|
||||||
|
REG(ds, 16, 0x12)
|
||||||
|
REG(es, 16, 0x13)
|
||||||
|
REG(fs, 16, 0x14)
|
||||||
|
REG(gs, 16, 0x15)
|
||||||
|
#ifndef ARCH_i386_real
|
||||||
|
REG(eax,32, 0x16)
|
||||||
|
REG(ebx,32, 0x17)
|
||||||
|
REG(ecx,32, 0x18)
|
||||||
|
REG(edx,32, 0x19)
|
||||||
|
REG(esi,32, 0x1a)
|
||||||
|
REG(edi,32, 0x1b)
|
||||||
|
REG(esp,32, 0x1c)
|
||||||
|
REG(ebp,32, 0x1d)
|
||||||
|
#endif /* !ARCH_i386_real */
|
||||||
|
REG(st0,32, 0x1f)
|
||||||
|
REG(st1,32, 0x20)
|
||||||
|
REG(st2,32, 0x21)
|
||||||
|
REG(st3,32, 0x22)
|
||||||
|
REG(st4,32, 0x23)
|
||||||
|
REG(st5,32, 0x24)
|
||||||
|
REG(st6,32, 0x25)
|
||||||
|
REG(st7,32, 0x26)
|
@ -1,8 +1,16 @@
|
|||||||
targets=sparc
|
targets=i386,sparc
|
||||||
cppflags_force=-I ../../include
|
cppflags_force=-I ../../include
|
||||||
cflags_force=-W
|
cflags_force=-W
|
||||||
cflags=-Wall -fPIC -pedantic
|
cflags=-Wall -fPIC -pedantic
|
||||||
dist=Makefile,common.ins,common.reg,null.ins,sparc.ins,sparc.reg
|
dist=Makefile,common.ins,i386.ins,i386.reg,null.ins,sparc.ins,sparc.reg
|
||||||
|
|
||||||
|
[i386]
|
||||||
|
type=plugin
|
||||||
|
sources=i386.c
|
||||||
|
install=$(LIBDIR)/asm/arch
|
||||||
|
|
||||||
|
[i386.c]
|
||||||
|
depends=common.ins,null.ins,i386.ins,i386.reg
|
||||||
|
|
||||||
[sparc]
|
[sparc]
|
||||||
type=plugin
|
type=plugin
|
||||||
@ -10,4 +18,4 @@ sources=sparc.c
|
|||||||
install=$(LIBDIR)/asm/arch
|
install=$(LIBDIR)/asm/arch
|
||||||
|
|
||||||
[sparc.c]
|
[sparc.c]
|
||||||
depends=common.ins,common.reg,null.ins,sparc.ins,sparc.reg
|
depends=common.ins,null.ins,sparc.ins,sparc.reg
|
||||||
|
16
src/code.c
16
src/code.c
@ -287,11 +287,23 @@ static int _instruction_fixed_register(Code * code, ArchOperand operand,
|
|||||||
static int _instruction_variable(Code * code, ArchInstruction * ai,
|
static int _instruction_variable(Code * code, ArchInstruction * ai,
|
||||||
AsOperand ** operands, size_t operands_cnt)
|
AsOperand ** operands, size_t operands_cnt)
|
||||||
{
|
{
|
||||||
|
size_t size;
|
||||||
|
char buf[8];
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||||
#endif
|
#endif
|
||||||
/* FIXME implement */
|
if((size = AO_GET_SIZE(ai->opcode)) > sizeof(buf))
|
||||||
return -1;
|
return -1; /* XXX report error */
|
||||||
|
if(size > 0)
|
||||||
|
{
|
||||||
|
memcpy(buf, &ai->value, size);
|
||||||
|
if(fwrite(&buf, size, 1, code->fp) != 1)
|
||||||
|
return -error_set_code(1, "%s: %s", code->filename,
|
||||||
|
strerror(errno));
|
||||||
|
}
|
||||||
|
/* FIXME implement operands */
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
switch(AO_GET_SIZE(ai->opcode))
|
switch(AO_GET_SIZE(ai->opcode))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
TARGETS = sparc.o
|
TARGETS = i386.o sparc.o
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
DESTDIR =
|
DESTDIR =
|
||||||
BINDIR = $(PREFIX)/bin
|
BINDIR = $(PREFIX)/bin
|
||||||
@ -12,14 +12,20 @@ INSTALL = install
|
|||||||
|
|
||||||
all: $(TARGETS)
|
all: $(TARGETS)
|
||||||
|
|
||||||
|
i386.o_OBJS = i386.o
|
||||||
|
i386.o_ASFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(ASFLAGS) -a i386 -f flat
|
||||||
|
|
||||||
sparc.o_OBJS = sparc.o
|
sparc.o_OBJS = sparc.o
|
||||||
sparc.o_ASFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(ASFLAGS) -a sparc
|
sparc.o_ASFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(ASFLAGS) -a sparc -f flat
|
||||||
|
|
||||||
|
i386.o: i386.S ../src/asm
|
||||||
|
$(AS) $(i386.o_ASFLAGS) -o i386.o i386.S
|
||||||
|
|
||||||
sparc.o: sparc.S ../src/asm
|
sparc.o: sparc.S ../src/asm
|
||||||
$(AS) $(sparc.o_ASFLAGS) -o sparc.o sparc.S
|
$(AS) $(sparc.o_ASFLAGS) -o sparc.o sparc.S
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) -- $(sparc.o_OBJS)
|
$(RM) -- $(i386.o_OBJS) $(sparc.o_OBJS)
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
$(RM) -- $(TARGETS)
|
$(RM) -- $(TARGETS)
|
||||||
|
2
test/i386.S
Normal file
2
test/i386.S
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.text
|
||||||
|
nop
|
@ -1,11 +1,19 @@
|
|||||||
targets=sparc.o
|
targets=i386.o,sparc.o
|
||||||
as=../src/asm
|
as=../src/asm
|
||||||
dist=Makefile
|
dist=Makefile
|
||||||
|
|
||||||
|
[i386.o]
|
||||||
|
type=object
|
||||||
|
sources=i386.S
|
||||||
|
|
||||||
|
[i386.S]
|
||||||
|
asflags=-a i386 -f flat
|
||||||
|
depends=../src/asm
|
||||||
|
|
||||||
[sparc.o]
|
[sparc.o]
|
||||||
type=object
|
type=object
|
||||||
sources=sparc.S
|
sources=sparc.S
|
||||||
|
|
||||||
[sparc.S]
|
[sparc.S]
|
||||||
asflags=-a sparc
|
asflags=-a sparc -f flat
|
||||||
depends=../src/asm
|
depends=../src/asm
|
||||||
|
Loading…
Reference in New Issue
Block a user