#include <rz_asm.h>
#include <rz_lib.h>
Go to the source code of this file.
◆ disassemble()
Definition at line 7 of file asm_chip8.c.
10 uint8_t y = (opcode >> 4) & 0x0F;
14 const char *buf_asm =
"invalid";
15 switch (opcode & 0xF000) {
17 if (opcode == 0x00E0) {
19 }
else if (opcode == 0x00EE) {
21 }
else if ((opcode & 0xFFF0) == 0x00C0) {
22 buf_asm =
sdb_fmt(
"scd 0x%01x", nibble);
23 }
else if (opcode == 0x00FB) {
25 }
else if (opcode == 0x00FC) {
27 }
else if (opcode == 0x00FD) {
29 }
else if (opcode == 0x00FE) {
31 }
else if (opcode == 0x00FF) {
35 case 0x1000: buf_asm =
sdb_fmt(
"jp 0x%03x", nnn);
break;
36 case 0x2000: buf_asm =
sdb_fmt(
"call 0x%03x", nnn);
break;
37 case 0x3000: buf_asm =
sdb_fmt(
"se v%1x, 0x%02x",
x, kk);
break;
38 case 0x4000: buf_asm =
sdb_fmt(
"sne v%1x, 0x%02x",
x, kk);
break;
39 case 0x5000: buf_asm =
sdb_fmt(
"se v%1x, v%1x",
x, y);
break;
40 case 0x6000: buf_asm =
sdb_fmt(
"ld v%1x, 0x%02x",
x, kk);
break;
41 case 0x7000: buf_asm =
sdb_fmt(
"add v%1x, 0x%02x",
x, kk);
break;
44 case 0x0: buf_asm =
sdb_fmt(
"ld v%1x, v%1x",
x, y);
break;
45 case 0x1: buf_asm =
sdb_fmt(
"or v%1x, v%1x",
x, y);
break;
46 case 0x2: buf_asm =
sdb_fmt(
"and v%1x, v%1x",
x, y);
break;
47 case 0x3: buf_asm =
sdb_fmt(
"xor v%1x, v%1x",
x, y);
break;
48 case 0x4: buf_asm =
sdb_fmt(
"add v%1x, v%1x",
x, y);
break;
49 case 0x5: buf_asm =
sdb_fmt(
"sub v%1x, v%1x",
x, y);
break;
50 case 0x6: buf_asm =
sdb_fmt(
"shr v%1x, v%1x",
x, y);
break;
51 case 0x7: buf_asm =
sdb_fmt(
"subn v%1x, v%1x",
x, y);
break;
52 case 0xE: buf_asm =
sdb_fmt(
"shl v%1x, v%1x",
x, y);
break;
55 case 0x9000: buf_asm =
sdb_fmt(
"sne v%1x, v%1x",
x, y);
break;
56 case 0xA000: buf_asm =
sdb_fmt(
"ld i, 0x%03x", nnn);
break;
57 case 0xB000: buf_asm =
sdb_fmt(
"jp v0, 0x%03x", nnn);
break;
58 case 0xC000: buf_asm =
sdb_fmt(
"rnd v%1x, 0x%02x",
x, kk);
break;
59 case 0xD000: buf_asm =
sdb_fmt(
"drw v%1x, v%1x, 0x%01x",
x, y, nibble);
break;
63 }
else if (kk == 0xA1) {
69 case 0x07: buf_asm =
sdb_fmt(
"ld v%1x, dt",
x);
break;
70 case 0x0A: buf_asm =
sdb_fmt(
"ld v%1x, k",
x);
break;
71 case 0x15: buf_asm =
sdb_fmt(
"ld dt, v%1x",
x);
break;
72 case 0x18: buf_asm =
sdb_fmt(
"ld st, v%1x",
x);
break;
73 case 0x1E: buf_asm =
sdb_fmt(
"add i, v%1x",
x);
break;
74 case 0x29: buf_asm =
sdb_fmt(
"ld f, v%1x",
x);
break;
75 case 0x33: buf_asm =
sdb_fmt(
"ld b, v%1x",
x);
break;
76 case 0x55: buf_asm =
sdb_fmt(
"ld [i], v%1x",
x);
break;
77 case 0x65: buf_asm =
sdb_fmt(
"ld v%1x, [i]",
x);
break;
78 case 0x30: buf_asm =
sdb_fmt(
"ld hf, v%1x",
x);
break;
79 case 0x75: buf_asm =
sdb_fmt(
"ld r, v%1x",
x);
break;
80 case 0x85: buf_asm =
sdb_fmt(
"ld v%1x, r",
x);
break;
RZ_API char * sdb_fmt(const char *fmt,...)
static ut16 rz_read_be16(const void *src)
RZ_API const char * rz_strbuf_set(RzStrBuf *sb, const char *s)
References b, rz_read_be16(), rz_strbuf_set(), sdb_fmt(), and x.
◆ rizin_plugin
Initial value:= {
}
RzAsmPlugin rz_asm_plugin_chip8
Definition at line 99 of file asm_chip8.c.
◆ rz_asm_plugin_chip8
Initial value:= {
.name = "chip8",
.arch = "chip8",
.license = "LGPL3",
.bits = 32,
.desc = "Chip8 disassembler",
}
static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *b, int l)
Definition at line 89 of file asm_chip8.c.