Re-introducing support for the Java architecture

This commit is contained in:
Pierre Pronchery 2011-04-22 17:53:02 +00:00
parent a932a7fc54
commit 24836cadfd
7 changed files with 533 additions and 6 deletions

View File

@ -54,6 +54,7 @@ dist:
$(PACKAGE)-$(VERSION)/src/arch/i486.c \
$(PACKAGE)-$(VERSION)/src/arch/i586.c \
$(PACKAGE)-$(VERSION)/src/arch/i686.c \
$(PACKAGE)-$(VERSION)/src/arch/java.c \
$(PACKAGE)-$(VERSION)/src/arch/sparc.c \
$(PACKAGE)-$(VERSION)/src/arch/sparc64.c \
$(PACKAGE)-$(VERSION)/src/arch/Makefile \
@ -82,6 +83,7 @@ dist:
$(PACKAGE)-$(VERSION)/test/i486.S \
$(PACKAGE)-$(VERSION)/test/i586.S \
$(PACKAGE)-$(VERSION)/test/i686.S \
$(PACKAGE)-$(VERSION)/test/java.S \
$(PACKAGE)-$(VERSION)/test/sparc.S \
$(PACKAGE)-$(VERSION)/test/sparc64.S \
$(PACKAGE)-$(VERSION)/test/Makefile \

View File

@ -1,4 +1,4 @@
TARGETS = i386.so i386_real.so i486.so i586.so i686.so sparc.so sparc64.so
TARGETS = i386.so i386_real.so i486.so i586.so i686.so java.so sparc.so sparc64.so
PREFIX = /usr/local
DESTDIR =
LIBDIR = $(PREFIX)/lib
@ -53,6 +53,13 @@ i686_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
i686.so: $(i686_OBJS)
$(LD) -o i686.so $(i686_OBJS) $(i686_LDFLAGS)
java_OBJS = java.o
java_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
java_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
java.so: $(java_OBJS)
$(LD) -o java.so $(java_OBJS) $(java_LDFLAGS)
sparc_OBJS = sparc.o
sparc_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
sparc_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
@ -82,6 +89,9 @@ i586.o: i586.c common.ins null.ins i386.h i386.ins i386.reg i486.ins i586.ins
i686.o: i686.c common.ins null.ins i386.h i386.ins i386.reg i486.ins i686.ins i686.reg
$(CC) $(i686_CFLAGS) -c i686.c
java.o: java.c common.ins null.ins
$(CC) $(java_CFLAGS) -c java.c
sparc.o: sparc.c common.ins null.ins sparc.h sparc.ins sparc.reg
$(CC) $(sparc_CFLAGS) -c sparc.c
@ -89,7 +99,7 @@ sparc64.o: sparc64.c common.ins null.ins sparc.h sparc.ins sparc.reg
$(CC) $(sparc64_CFLAGS) -c sparc64.c
clean:
$(RM) -- $(i386_OBJS) $(i386_real_OBJS) $(i486_OBJS) $(i586_OBJS) $(i686_OBJS) $(sparc_OBJS) $(sparc64_OBJS)
$(RM) -- $(i386_OBJS) $(i386_real_OBJS) $(i486_OBJS) $(i586_OBJS) $(i686_OBJS) $(java_OBJS) $(sparc_OBJS) $(sparc64_OBJS)
distclean: clean
$(RM) -- $(TARGETS)
@ -106,6 +116,8 @@ install: $(TARGETS)
$(MKDIR) $(DESTDIR)$(LIBDIR)/asm/arch
$(INSTALL) -m 0644 -- i686.so $(DESTDIR)$(LIBDIR)/asm/arch/i686.so
$(MKDIR) $(DESTDIR)$(LIBDIR)/asm/arch
$(INSTALL) -m 0644 -- java.so $(DESTDIR)$(LIBDIR)/asm/arch/java.so
$(MKDIR) $(DESTDIR)$(LIBDIR)/asm/arch
$(INSTALL) -m 0644 -- sparc.so $(DESTDIR)$(LIBDIR)/asm/arch/sparc.so
$(MKDIR) $(DESTDIR)$(LIBDIR)/asm/arch
$(INSTALL) -m 0644 -- sparc64.so $(DESTDIR)$(LIBDIR)/asm/arch/sparc64.so
@ -116,6 +128,7 @@ uninstall:
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/i486.so
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/i586.so
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/i686.so
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/java.so
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/sparc.so
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/sparc64.so

282
src/arch/java.c Normal file
View File

@ -0,0 +1,282 @@
/* $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 <System.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "Asm.h"
/* Java */
/* private */
/* variables */
static ArchDescription _java_description = { "java", ARCH_ENDIAN_BIG, 1, 0 };
static ArchRegister _java_registers[] =
{
{ NULL, 0, 0 }
};
#define OP1F (8 << AOD_SIZE)
#define OP_U8 AO_IMMEDIATE(0, 0, 8)
#define OP_U16 AO_IMMEDIATE(0, 0, 16)
#define OP_U32 AO_IMMEDIATE(0, 0, 32)
static ArchInstruction _java_instructions[] =
{
{ "aaload", 0x32, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "aastore", 0x53, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "aconst_null",0x01, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "aload", 0x19, OP1F, OP_U8, AOT_NONE, AOT_NONE },
{ "aload_0", 0x2a, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "aload_1", 0x2b, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "aload_2", 0x2c, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "aload_3", 0x2d, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "areturn", 0xb0, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "arraylength",0xbe, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "astore", 0x3a, OP1F, OP_U8, AOT_NONE, AOT_NONE },
{ "astore_0", 0x4b, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "astore_1", 0x4c, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "astore_2", 0x4d, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "astore_3", 0x4e, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "athrow", 0xbf, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "baload", 0x33, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "bastore", 0x54, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "bipush", 0x10, OP1F, OP_U32, AOT_NONE, AOT_NONE },
{ "caload", 0x34, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "castore", 0x55, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "checkcast", 0xc0, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "d2f", 0x90, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "d2i", 0x8e, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "d2l", 0x8f, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dadd", 0x63, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "daload", 0x31, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dastore", 0x52, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dcmpg", 0x98, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dcmpl", 0x97, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dconst_0", 0x0e, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dconst_1", 0x0f, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "ddiv", 0x6f, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dload", 0x18, OP1F, OP_U8, AOT_NONE, AOT_NONE },
{ "dload_0", 0x26, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dload_1", 0x27, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dload_2", 0x28, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dload_3", 0x29, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dmul", 0x6b, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dneg", 0x77, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "drem", 0x73, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dreturn", 0xaf, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dstore", 0x39, OP1F, OP_U8, AOT_NONE, AOT_NONE },
{ "dstore_0", 0x47, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dstore_1", 0x48, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dstore_2", 0x49, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dstore_3", 0x4a, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dsub", 0x67, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dup", 0x59, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dup_x1", 0x5a, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dup_x2", 0x5b, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dup2", 0x5c, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dup2_x1", 0x5d, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "dup2_x2", 0x5e, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "f2d", 0x8d, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "f2i", 0x8b, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "f2l", 0x8c, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "fadd", 0x62, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "faload", 0x30, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "fastore", 0x51, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "fcmpg", 0x96, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "fcmpl", 0x95, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "fconst_0", 0x0b, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "fconst_1", 0x0c, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "fconst_2", 0x0d, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "fdiv", 0x6e, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "fload", 0x17, OP1F, OP_U8, AOT_NONE, AOT_NONE },
{ "fload_0", 0x22, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "fload_1", 0x23, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "fload_2", 0x24, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "fload_3", 0x25, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "fmul", 0x6a, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "fneg", 0x76, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "frem", 0x72, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "freturn", 0xae, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "fstore_0", 0x43, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "fstore_1", 0x44, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "fstore_2", 0x45, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "fstore_3", 0x46, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "fsub", 0x66, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "getfield", 0xb4, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "getstatic", 0xb2, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "goto", 0xa7, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "goto_w", 0xc8, OP1F, OP_U32, AOT_NONE, AOT_NONE },
{ "i2b", 0x91, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "i2c", 0x92, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "i2d", 0x87, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "i2f", 0x86, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "i2l", 0x85, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "i2s", 0x93, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "iadd", 0x60, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "iaload", 0x2e, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "iand", 0x7e, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "iastore", 0x4f, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "iconst_m1", 0x02, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "iconst_0", 0x03, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "iconst_1", 0x04, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "iconst_2", 0x05, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "iconst_3", 0x06, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "iconst_4", 0x07, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "iconst_5", 0x08, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "idiv", 0x6c, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "if_acmpeq", 0xa5, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "if_acmpne", 0xa6, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "if_icmpeq", 0x9f, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "if_icmpne", 0xa0, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "if_icmplt", 0xa1, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "if_icmpge", 0xa2, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "if_icmpgt", 0xa3, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "if_icmple", 0xa4, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "ifeq", 0x99, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "ifne", 0x9a, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "iflt", 0x9b, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "ifge", 0x9c, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "ifgt", 0x9d, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "ifle", 0x9e, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "ifnonnull", 0xc7, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "ifnull", 0xc6, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "iinc", 0x84, OP1F, OP_U8, OP_U8, AOT_NONE },
{ "iload", 0x15, OP1F, OP_U8, AOT_NONE, AOT_NONE },
{ "iload_0", 0x1a, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "iload_1", 0x1b, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "iload_2", 0x1c, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "iload_3", 0x1d, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "impdep1", 0xfe, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "impdep2", 0xff, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "imul", 0x68, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "ineg", 0x74, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "instanceof", 0xc1, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "invokeinterface",0xb9,OP1F,OP_U16, OP_U8, AOT_NONE },
{ "invokespecial",0xb7, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "invokestatic",0xb8, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "invokevirtual",0xb6, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "ior", 0x80, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "irem", 0x70, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "ireturn", 0xac, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "ishl", 0x78, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "ishr", 0x7a, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "istore", 0x36, OP1F, OP_U8, AOT_NONE, AOT_NONE },
{ "istore_0", 0x3b, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "istore_0", 0x3c, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "istore_0", 0x3d, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "istore_3", 0x3e, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "isub", 0x64, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "iushr", 0x7c, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "ixor", 0x82, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "jsr", 0xa8, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "jsr_w", 0xc9, OP1F, OP_U32, AOT_NONE, AOT_NONE },
{ "l2d", 0x8a, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "l2f", 0x89, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "l2i", 0x88, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "ladd", 0x61, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "laload", 0x2f, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "land", 0x7f, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lastore", 0x50, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lcmp", 0x94, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lconst_0", 0x09, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lconst_1", 0x0a, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "ldc", 0x12, OP1F, OP_U8, AOT_NONE, AOT_NONE },
{ "ldc_w", 0x13, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "ldc2_w", 0x14, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "ldiv", 0x6d, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lload", 0x16, OP1F, OP_U8, AOT_NONE, AOT_NONE },
{ "lload_0", 0x1e, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lload_1", 0x1f, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lload_2", 0x20, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lload_3", 0x21, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lmul", 0x69, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lneg", 0x75, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lor", 0x81, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lrem", 0x71, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lreturn", 0xad, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lookupswitch",0xab, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lshl", 0x79, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lshr", 0x7b, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lstore", 0x37, OP1F, OP_U8, AOT_NONE, AOT_NONE },
{ "lstore_0", 0x3f, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lstore_1", 0x40, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lstore_2", 0x41, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lstore_3", 0x42, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lsub", 0x65, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lushr", 0x7d, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "lxor", 0x83, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "monitorenter",0xc2, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "monitorexit",0xc3, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "multianewarray",0xc5,OP1F, OP_U16, OP_U8, AOT_NONE },
{ "new", 0xbb, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "newarray", 0xbb, OP1F, OP_U8, AOT_NONE, AOT_NONE },
{ "nop", 0x00, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "pop", 0x57, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "pop2", 0x58, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "putfield", 0xb5, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "putstatic", 0xb3, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "ret", 0xa9, OP1F, OP_U8, AOT_NONE, AOT_NONE },
{ "return", 0xb1, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "saload", 0x35, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "sastore", 0x56, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "sipush", 0x11, OP1F, OP_U16, AOT_NONE, AOT_NONE },
{ "swap", 0x5f, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "tableswitch",0xaa, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
{ "wide", 0xc4, OP1F, OP_U8, OP_U16, AOT_NONE },
{ "wide", 0xc4, OP1F, OP_U8, OP_U8, OP_U16 },
{ "xxxunusedxxx",0xba, OP1F, AOT_NONE, AOT_NONE, AOT_NONE },
#include "common.ins"
#include "null.ins"
};
/* prototypes */
/* plug-in */
static int _java_write(ArchPlugin * plugin, ArchInstruction * instruction,
ArchInstructionCall * call);
/* public */
/* variables */
ArchPlugin arch_plugin =
{
NULL,
"java",
&_java_description,
_java_registers,
_java_instructions,
_java_write,
NULL
};
/* private */
/* functions */
/* plug-in */
static int _java_write(ArchPlugin * plugin, ArchInstruction * instruction,
ArchInstructionCall * call)
{
ArchPluginHelper * helper = plugin->helper;
/* FIXME really implement */
return (fwrite(&instruction->opcode, sizeof(instruction->opcode), 1,
helper->fp) == 1) ? 0
: -error_set_code(1, "%s: %s", helper->filename,
strerror(errno));
}

View File

@ -1,4 +1,4 @@
targets=i386,i386_real,i486,i586,i686,sparc,sparc64
targets=i386,i386_real,i486,i586,i686,java,sparc,sparc64
cppflags_force=-I ../../include
cflags_force=-W `pkg-config --cflags libSystem`
cflags=-Wall -fPIC -pedantic
@ -44,6 +44,14 @@ install=$(LIBDIR)/asm/arch
[i686.c]
depends=common.ins,null.ins,i386.h,i386.ins,i386.reg,i486.ins,i686.ins,i686.reg
[java]
type=plugin
sources=java.c
install=$(LIBDIR)/asm/arch
[java.c]
depends=common.ins,null.ins
[sparc]
type=plugin
sources=sparc.c

View File

@ -1,4 +1,4 @@
TARGETS = i386.o i386_real.o i486.o i586.o i686.o sparc.o sparc64.o
TARGETS = i386.o i386_real.o i486.o i586.o i686.o java.o sparc.o sparc64.o
PREFIX = /usr/local
DESTDIR =
BINDIR = $(PREFIX)/bin
@ -27,6 +27,9 @@ i586.o_ASFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(ASFLAGS) -a i586
i686.o_OBJS = i686.o
i686.o_ASFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(ASFLAGS) -a i686
java.o_OBJS = java.o
java.o_ASFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(ASFLAGS) -a java -f flat
sparc.o_OBJS = sparc.o
sparc.o_ASFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(ASFLAGS) -a sparc
@ -48,6 +51,9 @@ i586.o: i586.S ../src/asm
i686.o: i686.S ../src/asm
$(AS) $(i686.o_ASFLAGS) -o i686.o i686.S
java.o: java.S ../src/asm
$(AS) $(java.o_ASFLAGS) -o java.o java.S
sparc.o: sparc.S ../src/asm
$(AS) $(sparc.o_ASFLAGS) -o sparc.o sparc.S
@ -55,7 +61,7 @@ sparc64.o: sparc64.S ../src/asm
$(AS) $(sparc64.o_ASFLAGS) -o sparc64.o sparc64.S
clean:
$(RM) -- $(i386.o_OBJS) $(i386_real.o_OBJS) $(i486.o_OBJS) $(i586.o_OBJS) $(i686.o_OBJS) $(sparc.o_OBJS) $(sparc64.o_OBJS)
$(RM) -- $(i386.o_OBJS) $(i386_real.o_OBJS) $(i486.o_OBJS) $(i586.o_OBJS) $(i686.o_OBJS) $(java.o_OBJS) $(sparc.o_OBJS) $(sparc64.o_OBJS)
distclean: clean
$(RM) -- $(TARGETS)

208
test/java.S Normal file
View File

@ -0,0 +1,208 @@
.text
aaload
aastore
aconst_null
aload $0x01
aload_0
aload_1
aload_2
aload_3
areturn
arraylength
astore $0x01
astore_0
astore_1
astore_2
astore_3
athrow
baload
bastore
bipush $0x01
caload
castore
checkcast $0x01
d2f
d2i
d2l
dadd
daload
dastore
dcmpg
dcmpl
dconst_0
dconst_1
ddiv
dload $0x01
dload_0
dload_1
dload_2
dload_3
dmul
dneg
drem
dreturn
dstore $0x01
dstore_0
dstore_1
dstore_2
dstore_3
dsub
dup
dup_x1
dup_x2
dup2
dup2_x1
dup2_x2
f2d
f2i
f2l
fadd
faload
fastore
fcmpg
fcmpl
fconst_0
fconst_1
fconst_2
fdiv
fload $0x01
fload_0
fload_1
fload_2
fload_3
fmul
fneg
frem
freturn
fstore_0
fstore_1
fstore_2
fstore_3
fsub
getfield $0x01
getstatic $0x01
goto $0x01
goto_w $0x01
i2b
i2c
i2d
i2f
i2l
i2s
iadd
iaload
iand
iastore
iconst_m1
iconst_0
iconst_1
iconst_2
iconst_3
iconst_4
iconst_5
idiv
if_acmpeq $0x01
if_acmpne $0x01
if_icmpeq $0x01
if_icmpne $0x01
if_icmplt $0x01
if_icmpge $0x01
if_icmpgt $0x01
if_icmple $0x01
ifeq $0x01
ifne $0x01
iflt $0x01
ifge $0x01
ifgt $0x01
ifle $0x01
ifnonnull $0x01
ifnull $0x01
iinc $0x01, $0x02
iload $0x01
iload_0
iload_1
iload_2
iload_3
impdep1
impdep2
imul
ineg
instanceof $0x01
invokeinterface $0x01, $0x02
invokespecial $0x01
invokestatic $0x01
invokevirtual $0x01
ior
irem
ireturn
ishl
ishr
istore $0x01
istore_0
istore_0
istore_0
istore_3
isub
iushr
ixor
jsr $0x01
jsr_w $0x01
l2d
l2f
l2i
ladd
laload
land
lastore
lcmp
lconst_0
lconst_1
ldc $0x01
ldc_w $0x01
ldc2_w $0x01
ldiv
lload $0x01
lload_0
lload_1
lload_2
lload_3
lmul
lneg
lor
lrem
lreturn
lookupswitch
lshl
lshr
lstore $0x01
lstore_0
lstore_1
lstore_2
lstore_3
lsub
lushr
lxor
monitorenter
monitorexit
multianewarray $0x01, $0x02
new $0x01
newarray $0x01
nop
pop
pop2
putfield $0x01
putstatic $0x01
ret $0x01
return
saload
sastore
sipush $0x01
swap
tableswitch
wide $0x01, $0x02
wide $0x01, $0x02, $0x03
xxxunusedxxx
#if 0 /* XXX not supported again yet */
/* db */
db $0x04
#endif

View File

@ -1,4 +1,4 @@
targets=i386.o,i386_real.o,i486.o,i586.o,i686.o,sparc.o,sparc64.o
targets=i386.o,i386_real.o,i486.o,i586.o,i686.o,java.o,sparc.o,sparc64.o
as=../src/asm
dist=Makefile
@ -42,6 +42,14 @@ sources=i686.S
asflags=-a i686
depends=../src/asm
[java.o]
type=object
sources=java.S
[java.S]
asflags=-a java -f flat
depends=../src/asm
[sparc.o]
type=object
sources=sparc.S