Skip to content

Commit d4203a9

Browse files
radaretrufae
authored andcommitted
Get rid of the dupped ut8p macros
1 parent 685f145 commit d4203a9

File tree

4 files changed

+12
-20
lines changed

4 files changed

+12
-20
lines changed

libr/arch/p/snes/plugin.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ static char *snes_disass(struct snes_asm_flags snesflags, ut64 pc, const ut8 *bu
4848
if (*buf == 0x44 || *buf == 0x54) { // mvp and mvn
4949
buf_asm = r_strf (s_op->name, buf[1], buf[2]);
5050
} else if (*buf == 0x82) { // brl
51-
buf_asm = r_strf (s_op->name, pc + 3 + (st16)ut8p_bw(buf + 1));
51+
buf_asm = r_strf (s_op->name, pc + 3 + (st16)r_read_le16(buf + 1));
5252
} else {
53-
buf_asm = r_strf (s_op->name, ut8p_bw (buf + 1));
53+
buf_asm = r_strf (s_op->name, r_read_le16 (buf + 1));
5454
}
5555
break;
5656
case SNES_OP_32BIT:
@@ -60,14 +60,14 @@ static char *snes_disass(struct snes_asm_flags snesflags, ut64 pc, const ut8 *bu
6060
if (M_flag) {
6161
buf_asm = r_strf ("%s #0x%02x", s_op->name, buf[1]);
6262
} else {
63-
buf_asm = r_strf ("%s #0x%04x", s_op->name, ut8p_bw (buf + 1));
63+
buf_asm = r_strf ("%s #0x%04x", s_op->name, r_read_le16 (buf + 1));
6464
}
6565
break;
6666
case SNES_OP_IMM_X:
6767
if (X_flag) {
6868
buf_asm = r_strf ("%s #0x%02x", s_op->name, buf[1]);
6969
} else {
70-
buf_asm = r_strf ("%s #0x%04x", s_op->name, ut8p_bw (buf + 1));
70+
buf_asm = r_strf ("%s #0x%04x", s_op->name, r_read_le16 (buf + 1));
7171
}
7272
break;
7373
}
@@ -248,7 +248,7 @@ static bool snes_anop(RArchSession *as, RAnalOp *op, RArchDecodeMask mask) {
248248
break;
249249
case 0x4c: // jmp addr
250250
op->eob = true;
251-
op->jump = (addr & 0xFF0000) | ut8p_bw (data + 1);
251+
op->jump = (addr & 0xFF0000) | r_read_le16 (data + 1);
252252
op->type = R_ANAL_OP_TYPE_JMP;
253253
break;
254254
case 0x5c: // jmp long
@@ -263,7 +263,7 @@ static bool snes_anop(RArchSession *as, RAnalOp *op, RArchDecodeMask mask) {
263263
break;
264264
case 0x82: // brl
265265
op->eob = true;
266-
op->jump = addr + 3 + (st16)ut8p_bw (data + 1);
266+
op->jump = addr + 3 + (st16)r_read_le16 (data + 1);
267267
op->type = R_ANAL_OP_TYPE_JMP;
268268
break;
269269
case 0x6c: // jmp (addr)
@@ -298,7 +298,7 @@ static bool snes_anop(RArchSession *as, RAnalOp *op, RArchDecodeMask mask) {
298298
op->type = R_ANAL_OP_TYPE_CJMP;
299299
break;
300300
case 0x20: // jsr addr
301-
op->jump = (addr & 0xFF0000) | ut8p_bw (data+1);
301+
op->jump = (addr & 0xFF0000) | r_read_le16 (data+1);
302302
op->type = R_ANAL_OP_TYPE_CALL;
303303
break;
304304
case 0x22: // jsr long

libr/arch/p/snes/snesdis.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ static int snesDisass(int M_flag, int X_flag, ut64 pc, RAnalOp *op, const ut8 *b
2828
if (*buf == 0x44 || *buf == 0x54) { // mvp and mvn
2929
op->mnemonic = r_str_newf (s_op->name, buf[1], buf[2]);
3030
} else if (*buf == 0x82) { // brl
31-
op->mnemonic = r_str_newf (s_op->name, pc + 3 + (st16)ut8p_bw(buf + 1));
31+
op->mnemonic = r_str_newf (s_op->name, pc + 3 + (st16)r_read_le16(buf + 1));
3232
} else {
33-
op->mnemonic = r_str_newf (s_op->name, ut8p_bw (buf + 1));
33+
op->mnemonic = r_str_newf (s_op->name, r_read_le16 (buf + 1));
3434
}
3535
break;
3636
case SNES_OP_32BIT:
@@ -40,14 +40,14 @@ static int snesDisass(int M_flag, int X_flag, ut64 pc, RAnalOp *op, const ut8 *b
4040
if (M_flag) {
4141
op->mnemonic = r_str_newf ("%s #0x%02x", s_op->name, buf[1]);
4242
} else {
43-
op->mnemonic = r_str_newf ("%s #0x%04x", s_op->name, ut8p_bw (buf + 1));
43+
op->mnemonic = r_str_newf ("%s #0x%04x", s_op->name, r_read_le16 (buf + 1));
4444
}
4545
break;
4646
case SNES_OP_IMM_X:
4747
if (X_flag) {
4848
op->mnemonic = r_str_newf ("%s #0x%02x", s_op->name, buf[1]);
4949
} else {
50-
op->mnemonic = r_str_newf ("%s #0x%04x", s_op->name, ut8p_bw (buf + 1));
50+
op->mnemonic = r_str_newf ("%s #0x%04x", s_op->name, r_read_le16 (buf + 1));
5151
}
5252
break;
5353
}

libr/bin/format/omf/omf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ bool r_bin_checksum_omf_ok(const ut8 *buf, ut64 buf_size) {
3030
eprintf ("Invalid record (too short)\n");
3131
return false;
3232
}
33-
size = ut8p_bw (buf + 1);
33+
size = r_read_le16 (buf + 1);
3434
if (buf_size < size + 3) {
3535
eprintf ("Invalid record (too short)\n");
3636
return false;

libr/include/r_endian.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -390,14 +390,6 @@ static inline void r_write_ble(void *dst, ut64 val, bool be, int size) {
390390
}
391391
}
392392

393-
// TODO: find better names and write vapis
394-
#define ut8p_b(x) ((x)[0])
395-
#define ut8p_bw(x) ((x)[0]|((x)[1]<<8))
396-
#define ut8p_bd(x) ((x)[0]|((x)[1]<<8)|((x)[2]<<16)|((x)[3]<<24))
397-
#define ut8p_bq(x) ((x)[0]|((x)[1]<<8)|((x)[2]<<16)|((x)[3]<<24)|((x)[4]<<32)|((x)[5]<<40)|((x)[6]<<48)|((x)[7]<<56))
398-
#define ut8p_lw(x) ((x)[1]|((x)[0]<<8))
399-
#define ut8p_ld(x) ((x)[3]|((x)[2]<<8)|((x)[1]<<16)|((x)[0]<<24))
400-
#define ut8p_lq(x) ((x)[7]|((x)[6]<<8)|((x)[5]<<16)|((x)[4]<<24)|((x)[3]<<32)|((x)[2]<<40)|((x)[1]<<48)|((x)[0]<<56))
401393

402394
/*swap*/
403395
static inline ut16 r_swap_ut16(ut16 val) {

0 commit comments

Comments
 (0)