Rizin
unix-like reverse engineering framework and cli tools
or1k_disas.c File Reference
#include <rz_analysis.h>
#include "or1k_disas.h"

Go to the source code of this file.

Functions

insn_extra_tfind_extra_descriptor (insn_extra_t *extra_descr, ut32 insn)
 
ut32 sign_extend (ut32 number, ut32 mask)
 Performs sign extension of number. More...
 

Variables

insn_type_descr_t types []
 
size_t types_count = sizeof(types) / sizeof(insn_type_descr_t)
 
insn_extra_t extra_0x5 []
 
insn_extra_t extra_0x6 []
 
insn_extra_t extra_0x8 []
 
insn_extra_t extra_0x2e []
 
insn_extra_t extra_0x2f []
 
insn_extra_t extra_0x31 []
 
insn_extra_t extra_0x32 []
 
insn_extra_t extra_0x38 []
 
insn_extra_t extra_0x39 []
 
insn_t or1k_insns []
 
size_t insns_count = sizeof(or1k_insns) / sizeof(insn_t)
 

Function Documentation

◆ find_extra_descriptor()

insn_extra_t* find_extra_descriptor ( insn_extra_t extra_descr,
ut32  insn 
)

Definition at line 288 of file or1k_disas.c.

288  {
289  ut32 opcode;
290  while (extra_descr->type != INSN_END) {
291  opcode = (insn & extra_descr->opcode_mask);
292  if (extra_descr->opcode == opcode) {
293  break;
294  }
295  extra_descr++;
296  }
297  if (extra_descr->type != INSN_END) {
298  return extra_descr;
299  } else {
300  return NULL;
301  }
302 }
#define NULL
Definition: cris-opc.c:27
uint32_t ut32
@ INSN_END
Definition: or1k_disas.h:53

References INSN_END, NULL, insn_extra_t::opcode, insn_extra_t::opcode_mask, and insn_extra_t::type.

Referenced by disassemble(), and or1k_op().

◆ sign_extend()

ut32 sign_extend ( ut32  number,
ut32  mask 
)

Performs sign extension of number.

Parameters
numbernumber to extend
maskmask under which number is placed
Returns
sign-extended number

If mask does not begin on the lsb, space on the right will also be filled with ones

Definition at line 304 of file or1k_disas.c.

304  {
305  /* xor of mask with itself shifted left detects msb of mask and msb of space
306  * on the right. And discards the latter */
307  ut32 first_bit = (mask ^ (mask >> 1)) & mask;
308  /* if first bit is set */
309  if (number & first_bit) {
310  /* set every bit outside mask */
311  number |= ~mask;
312  }
313  return number;
314 }
#define mask()

References mask.

Variable Documentation

◆ extra_0x2e

insn_extra_t extra_0x2e[]
Initial value:
= {
{ (0x2e << 26) | (0x0 << 6), "l.slli", INSN_DAL, INSN_OPCODE_MASK | (0x3 << 6) },
{ (0x2e << 26) | (0x1 << 6), "l.srli", INSN_DAL, INSN_OPCODE_MASK | (0x3 << 6) },
{ (0x2e << 26) | (0x2 << 6), "l.srai", INSN_DAL, INSN_OPCODE_MASK | (0x3 << 6) },
{ (0x2e << 26) | (0x3 << 6), "l.rori", INSN_DAL, INSN_OPCODE_MASK | (0x3 << 6) },
{ 0 }
}
@ INSN_DAL
Definition: or1k_disas.h:67
#define INSN_OPCODE_MASK
Definition: or1k_disas.h:10

Definition at line 98 of file or1k_disas.c.

◆ extra_0x2f

insn_extra_t extra_0x2f[]
Initial value:
= {
{ (0x2f << 26) | (0x0 << 21), "l.sfeqi", INSN_AI, INSN_OPCODE_MASK | (0x1f << 21) },
{ (0x2f << 26) | (0x1 << 21), "l.sfnei", INSN_AI, INSN_OPCODE_MASK | (0x1f << 21) },
{ (0x2f << 26) | (0x2 << 21), "l.sfgtui", INSN_AI, INSN_OPCODE_MASK | (0x1f << 21) },
{ (0x2f << 26) | (0x3 << 21), "l.sfgeui", INSN_AI, INSN_OPCODE_MASK | (0x1f << 21) },
{ (0x2f << 26) | (0x4 << 21), "l.sfltui", INSN_AI, INSN_OPCODE_MASK | (0x1f << 21) },
{ (0x2f << 26) | (0x5 << 21), "l.sfleui", INSN_AI, INSN_OPCODE_MASK | (0x1f << 21) },
{ (0x2f << 26) | (0xa << 21), "l.sfgtsi", INSN_AI, INSN_OPCODE_MASK | (0x1f << 21) },
{ (0x2f << 26) | (0xb << 21), "l.sfgesi", INSN_AI, INSN_OPCODE_MASK | (0x1f << 21) },
{ (0x2f << 26) | (0xc << 21), "l.sfltsi", INSN_AI, INSN_OPCODE_MASK | (0x1f << 21) },
{ (0x2f << 26) | (0xd << 21), "l.sflesi", INSN_AI, INSN_OPCODE_MASK | (0x1f << 21) },
{ 0 }
}
@ INSN_AI
Definition: or1k_disas.h:62

Definition at line 106 of file or1k_disas.c.

◆ extra_0x31

insn_extra_t extra_0x31[]
Initial value:
= {
{ (0x31 << 26) | (0x1), "l.mac", INSN_AB, INSN_OPCODE_MASK | (0xf) },
{ (0x31 << 26) | (0x3), "l.macu", INSN_AB, INSN_OPCODE_MASK | (0xf) },
{ (0x31 << 26) | (0x2), "l.msb", INSN_AB, INSN_OPCODE_MASK | (0xf) },
{ (0x31 << 26) | (0x4), "l.msbu", INSN_AB, INSN_OPCODE_MASK | (0xf) },
{ 0 }
}
@ INSN_AB
Definition: or1k_disas.h:71

Definition at line 120 of file or1k_disas.c.

◆ extra_0x32

insn_extra_t extra_0x32[]

Definition at line 128 of file or1k_disas.c.

◆ extra_0x38

insn_extra_t extra_0x38[]
Initial value:
= {
{ (0x38 << 26) | (0x0 << 6) | (0xc), "l.exths", INSN_DA, INSN_OPCODE_MASK | (0xf << 6) | 0xf },
{ (0x38 << 26) | (0x0 << 6) | (0xd), "l.extws", INSN_DA, INSN_OPCODE_MASK | (0xf << 6) | 0xf },
{ (0x38 << 26) | (0x1 << 6) | (0xc), "l.extbs", INSN_DA, INSN_OPCODE_MASK | (0xf << 6) | 0xf },
{ (0x38 << 26) | (0x1 << 6) | (0xd), "l.extwz", INSN_DA, INSN_OPCODE_MASK | (0xf << 6) | 0xf },
{ (0x38 << 26) | (0x2 << 6) | (0xc), "l.exthz", INSN_DA, INSN_OPCODE_MASK | (0xf << 6) | 0xf },
{ (0x38 << 26) | (0x3 << 6) | (0xc), "l.extbz", INSN_DA, INSN_OPCODE_MASK | (0xf << 6) | 0xf },
{ (0x38 << 26) | (0x0 << 6) | (0x0), "l.add", INSN_DAB, INSN_OPCODE_MASK | (0xc << 6) | 0xf },
{ (0x38 << 26) | (0x0 << 6) | (0x1), "l.addc", INSN_DAB, INSN_OPCODE_MASK | (0xc << 6) | 0xf },
{ (0x38 << 26) | (0x0 << 6) | (0x2), "l.sub", INSN_DAB, INSN_OPCODE_MASK | (0xc << 6) | 0xf },
{ (0x38 << 26) | (0x0 << 6) | (0x3), "l.and", INSN_DAB, INSN_OPCODE_MASK | (0xc << 6) | 0xf },
{ (0x38 << 26) | (0x0 << 6) | (0x4), "l.or", INSN_DAB, INSN_OPCODE_MASK | (0xc << 6) | 0xf },
{ (0x38 << 26) | (0x0 << 6) | (0x5), "l.xor", INSN_DAB, INSN_OPCODE_MASK | (0xc << 6) | 0xf },
{ (0x38 << 26) | (0x0 << 6) | (0xe), "l.cmov", INSN_DAB, INSN_OPCODE_MASK | (0xc << 6) | 0xf },
{ (0x38 << 26) | (0x0 << 6) | (0xf), "l.ff1", INSN_DA, INSN_OPCODE_MASK | (0xc << 6) | 0xf },
{ (0x38 << 26) | (0x0 << 6) | (0x8), "l.sll", INSN_DAB, INSN_OPCODE_MASK | (0xf << 6) | 0xf },
{ (0x38 << 26) | (0x1 << 6) | (0x8), "l.srl", INSN_DAB, INSN_OPCODE_MASK | (0xf << 6) | 0xf },
{ (0x38 << 26) | (0x2 << 6) | (0x8), "l.sra", INSN_DAB, INSN_OPCODE_MASK | (0xf << 6) | 0xf },
{ (0x38 << 26) | (0x3 << 6) | (0x8), "l.ror", INSN_DAB, INSN_OPCODE_MASK | (0xf << 6) | 0xf },
{ (0x38 << 26) | (0x1 << 8) | (0xf), "l.fl1", INSN_DA, INSN_OPCODE_MASK | (0x3 << 8) | 0xf },
{ (0x38 << 26) | (0x3 << 8) | (0x6), "l.mul", INSN_DAB, INSN_OPCODE_MASK | (0x3 << 8) | 0xf },
{ (0x38 << 26) | (0x3 << 8) | (0x7), "l.muld", INSN_AB, INSN_OPCODE_MASK | (0x3 << 8) | 0xf },
{ (0x38 << 26) | (0x3 << 8) | (0x9), "l.div", INSN_DAB, INSN_OPCODE_MASK | (0x3 << 8) | 0xf },
{ (0x38 << 26) | (0x3 << 8) | (0xa), "l.divu", INSN_DAB, INSN_OPCODE_MASK | (0x3 << 8) | 0xf },
{ (0x38 << 26) | (0x3 << 8) | (0xb), "l.mulu", INSN_DAB, INSN_OPCODE_MASK | (0x3 << 8) | 0xf },
{ (0x38 << 26) | (0x3 << 8) | (0xc), "l.muldu", INSN_AB, INSN_OPCODE_MASK | (0x3 << 8) | 0xf },
{ 0 }
}
@ INSN_DAB
Definition: or1k_disas.h:73
@ INSN_DA
Definition: or1k_disas.h:72

Definition at line 176 of file or1k_disas.c.

◆ extra_0x39

insn_extra_t extra_0x39[]
Initial value:
= {
{ (0x39 << 26) | (0x0 << 21), "l.sfeq", INSN_AB, INSN_OPCODE_MASK | (0x1f << 21) },
{ (0x39 << 26) | (0x1 << 21), "l.sfne", INSN_AB, INSN_OPCODE_MASK | (0x1f << 21) },
{ (0x39 << 26) | (0x2 << 21), "l.sfgtu", INSN_AB, INSN_OPCODE_MASK | (0x1f << 21) },
{ (0x39 << 26) | (0x3 << 21), "l.sfgeu", INSN_AB, INSN_OPCODE_MASK | (0x1f << 21) },
{ (0x39 << 26) | (0x4 << 21), "l.sfltu", INSN_AB, INSN_OPCODE_MASK | (0x1f << 21) },
{ (0x39 << 26) | (0x5 << 21), "l.sfleu", INSN_AB, INSN_OPCODE_MASK | (0x1f << 21) },
{ (0x39 << 26) | (0xa << 21), "l.sfgts", INSN_AB, INSN_OPCODE_MASK | (0x1f << 21) },
{ (0x39 << 26) | (0xb << 21), "l.sfges", INSN_AB, INSN_OPCODE_MASK | (0x1f << 21) },
{ (0x39 << 26) | (0xc << 21), "l.sflts", INSN_AB, INSN_OPCODE_MASK | (0x1f << 21) },
{ (0x39 << 26) | (0xd << 21), "l.sfles", INSN_AB, INSN_OPCODE_MASK | (0x1f << 21) },
{ 0 }
}

Definition at line 205 of file or1k_disas.c.

◆ extra_0x5

insn_extra_t extra_0x5[]
Initial value:
= {
{ (0x05 << 26) | (0x1 << 24), "l.nop", INSN_K, INSN_OPCODE_MASK | (0x3 << 24), RZ_ANALYSIS_OP_TYPE_NOP },
{ 0 }
}
@ INSN_K
Definition: or1k_disas.h:58
@ RZ_ANALYSIS_OP_TYPE_NOP
Definition: rz_analysis.h:389

Definition at line 78 of file or1k_disas.c.

◆ extra_0x6

insn_extra_t extra_0x6[]
Initial value:
= {
{ (0x06 << 26) | (0 << 16), "l.movhi", INSN_DK, INSN_OPCODE_MASK | (1 << 16) },
{ (0x06 << 26) | (1 << 16), "l.macrc", INSN_D, INSN_OPCODE_MASK | (1 << 16) },
{ 0 }
}
@ INSN_D
Definition: or1k_disas.h:60
@ INSN_DK
Definition: or1k_disas.h:59

Definition at line 83 of file or1k_disas.c.

◆ extra_0x8

insn_extra_t extra_0x8[]
Initial value:
= {
{ (0x08 << 26) | (0x0), "l.sys", INSN_K, INSN_OPCODE_MASK | 0x3ff << 16 },
{ (0x08 << 26) | (0x100), "l.trap", INSN_K, INSN_OPCODE_MASK | 0x3ff << 16 },
{ (0x08 << 26) | (0x2000000), "l.msync", INSN_X, INSN_OPCODE_MASK | 0x3ffffff },
{ (0x08 << 26) | (0x2800000), "l.psync", INSN_X, INSN_OPCODE_MASK | 0x3ffffff },
{ (0x08 << 26) | (0x3000000), "l.csync", INSN_X, INSN_OPCODE_MASK | 0x3ffffff },
{ 0 }
}
@ INSN_X
Definition: or1k_disas.h:55

Definition at line 89 of file or1k_disas.c.

◆ insns_count

size_t insns_count = sizeof(or1k_insns) / sizeof(insn_t)

Definition at line 286 of file or1k_disas.c.

Referenced by disassemble(), and or1k_op().

◆ or1k_insns

insn_t or1k_insns[]

Definition at line 219 of file or1k_disas.c.

Referenced by disassemble(), and or1k_op().

◆ types

◆ types_count

size_t types_count = sizeof(types) / sizeof(insn_type_descr_t)

Definition at line 76 of file or1k_disas.c.

Referenced by has_type_descriptor().