add 6502-disassembler + make asm.snes shared

This commit is contained in:
condret 2014-02-24 15:51:24 +01:00 committed by pancake
parent 2590e997b1
commit ca1644eaea
6 changed files with 168 additions and 2 deletions

View File

@ -0,0 +1,118 @@
#include <r_asm.h>
#include <r_lib.h>
#include <string.h>
#include "../snes/snesdis.c"
static int _6502Disass (RAsmOp *op, const ut8 *buf, ut64 len)
{
switch (*buf) {
case 0x80:
case 0x02:
case 0x03:
case 0x04:
case 0x12:
case 0x13:
case 0x14:
case 0x22:
case 0x23:
case 0x32:
case 0x33:
case 0x34:
case 0x42:
case 0x43:
case 0x44:
case 0x52:
case 0x53:
case 0x54:
case 0x62:
case 0x63:
case 0x64:
case 0x72:
case 0x73:
case 0x74:
case 0x82:
case 0x83:
case 0x92:
case 0x93:
case 0xa3:
case 0xb2:
case 0xb3:
case 0xc2:
case 0xc3:
case 0xd2:
case 0xd3:
case 0xd4:
case 0xe2:
case 0xe3:
case 0xf2:
case 0xf3:
case 0xf4:
case 0x07:
case 0x17:
case 0x27:
case 0x37:
case 0x47:
case 0x57:
case 0x67:
case 0x77:
case 0x87:
case 0x97:
case 0xa7:
case 0xb7:
case 0xc7:
case 0xd7:
case 0xe7:
case 0xf7:
case 0x89:
case 0x0b:
case 0x0c:
case 0x1a:
case 0x1b:
case 0x1c:
case 0x2b:
case 0x3a:
case 0x3b:
case 0x3c:
case 0x4b:
case 0x5a:
case 0x5b:
case 0x5c:
case 0x6b:
case 0x7a:
case 0x7b:
case 0x7c:
case 0x8b:
case 0x9b:
case 0x9c:
case 0xab:
case 0xbb:
case 0xcb:
case 0xda:
case 0xdb:
case 0xdc:
case 0xeb:
case 0xfa:
case 0xfb:
case 0xfc:
case 0x0f:
case 0x1f:
case 0x2f:
case 0x3f:
case 0x4f:
case 0x5f:
case 0x6f:
case 0x7f:
case 0x8f:
case 0x9e:
case 0x9f:
case 0xaf:
case 0xbf:
case 0xcf:
case 0xdf:
case 0xef:
case 0xff:
strcpy (op->buf_asm, "illegal");
return 1;
}
return snesDisass (op, buf, len);
}

9
libr/asm/p/6502.mk Normal file
View File

@ -0,0 +1,9 @@
OBJ_6502=asm_6502.o
STATIC_OBJ+=${OBJ_6502}
TARGET_6502=asm_6502.${EXT_SO}
ALL_TARGETS+=${TARGET_6502}
${TARGET_6502}: ${OBJ_6502}
${CC} ${call libname,asm_6502} ${CFLAGS} -o ${TARGET_6502} ${OBJ_6502}

View File

@ -13,7 +13,7 @@ ALL_TARGETS=
# TODO: rename to enabled plugins
ARCHS=mips.mk sparc.mk java.mk bf.mk arm.mk dalvik.mk x86_as.mk x86_nz.mk
ARCHS+=ppc.mk x86_olly.mk x86.mk csr.mk x86_nasm.mk psosvm.mk avr.mk
ARCHS+=msil.mk sh.mk arm_winedbg.mk tms320.mk gb.mk snes.mk ebc.mk malbolge.mk ws.mk
ARCHS+=msil.mk sh.mk arm_winedbg.mk tms320.mk gb.mk snes.mk ebc.mk malbolge.mk ws.mk 6502.mk
include $(ARCHS)
all: ${ALL_TARGETS}

37
libr/asm/p/asm_6502.c Normal file
View File

@ -0,0 +1,37 @@
/* radare - LGPL - Copyright 2012-2013 - pancake
2014 - condret */
// copypasta from asm_gb.c
#include <r_types.h>
#include <r_util.h>
#include <r_asm.h>
#include <r_lib.h>
#include "../arch/6502/6502dis.c"
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, ut64 len) {
int dlen = _6502Disass (op,buf,len);
if(dlen<0) dlen=0;
op->size=dlen;
return dlen;
}
RAsmPlugin r_asm_plugin_6502 = {
.name = "6502",
.desc = "6502/NES disassembly plugin",
.arch = "6502",
.bits = 8|16,
.init = NULL,
.fini = NULL,
.license = "LGPL3",
.disassemble = &disassemble,
.modify = NULL,
.assemble = NULL,
};
#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
.type = R_LIB_TYPE_ASM,
.data = &r_asm_plugin_6502
};
#endif

View File

@ -189,6 +189,7 @@ extern RAsmPlugin r_asm_plugin_ebc;
extern RAsmPlugin r_asm_plugin_nios2;
extern RAsmPlugin r_asm_plugin_malbolge;
extern RAsmPlugin r_asm_plugin_ws;
extern RAsmPlugin r_asm_plugin_6502;
#endif
#ifdef __cplusplus

View File

@ -31,7 +31,6 @@ asm.8051
asm.msil
asm.tms320
asm.gb
asm.snes
asm.ebc
asm.malbolge
asm.ws
@ -134,4 +133,6 @@ parse.dalvik_pseudo
parse.x86_pseudo"
SHARED="
asm.psosvm
asm.snes
asm.6502
io.shm"