28 bool inside_paren =
false;
30 for (
ut8 i = 0; spaced[
i] !=
'\0';
i++) {
59 const int reg_num =
sizeof(
sh_registers) /
sizeof(
char *);
60 for (
ut8 i = 0;
i < reg_num;
i++) {
69 RZ_LOG_ERROR(
"SuperH: Invalid register encountered by the assembler\n");
92 char *
const disp =
strdup(param);
103 sscanf(param,
"@%s",
reg);
108 char *plus = strchr(
dup,
'+');
119 sscanf(param,
"@-%s",
reg);
129 sscanf(
dup,
"@(%s", disp);
132 char *paren = strchr(
comma,
')');
145 char *paren = strchr(
dup,
')');
150 paren =
dup + strlen(
"@(r0,");
161 sscanf(
dup,
"@(%s", disp);
173 sscanf(
dup,
"@(%s,pc)", disp);
193 RZ_LOG_ERROR(
"SuperH: Invalid addressing mode encountered by the assembler\n");
212 char *
const dup =
strdup(reg_disp_indirect);
219 char *paren = strchr(
reg,
')');
225 char *
const disp =
strdup(reg_disp_indirect);
226 sscanf(
dup,
"@(%s", disp);
261 for (
ut8 i = 0;
i < reg_num;
i++) {
292 if (strcmp(param,
"@(r0,gbr)") == 0) {
342 for (
ut8 i = 0;
i < 2;
i++) {
418 rz_list_foreach_safe (tokens, itr,
tmp, tok) {
424 if (token_num == 0 || token_num > 3) {
425 RZ_LOG_ERROR(
"SuperH: Invalid number of operands in the instruction\n")
432 rz_list_foreach (tokens, itr, tok) {
455 free(reg_disp_indirect);
462 rz_list_foreach (tokens, itr, param) {
void bye(char *msg1, char *msg2)
RZ_API void Ht_() free(HtName_(Ht) *ht)
RZ_API void rz_list_delete(RZ_NONNULL RzList *list, RZ_NONNULL RzListIter *iter)
Removes an entry in the list by using the RzListIter pointer.
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list)
Returns the length of the list.
RZ_API RZ_OWN void * rz_list_pop_head(RZ_NONNULL RzList *list)
Removes and returns the first element of the list.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode dup
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
static const char * sh_registers[]
#define rz_warn_if_reached()
#define rz_return_val_if_fail(expr, val)
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API ut64 rz_num_get(RzNum *num, const char *str)
RZ_API int RZ_API bool rz_str_is_whitespace(RZ_NONNULL const char *str)
Checks if the whole string is composed of whitespace.
RZ_API RzList * rz_str_split_duplist(const char *str, const char *c, bool trim)
Split the string str according to the substring c and returns a RzList with the result.
RZ_API bool rz_str_startswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle)
Checks if a string starts with a specifc sequence of characters (case sensitive)
RZ_API bool rz_str_endswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle)
Checks if a string ends with a specifc sequence of characters (case sensitive)
static SHAddrMode sh_pb_get_addrmode(SHParamBuilder pb)
Get the addressing mode for pb.
static ut32 sh_op_reg_bits(const char *param, ut8 offset)
Get the bits corresponding to the register param (i.e. register number shifted at offset)
static bool sh_op_compare(SHOpRaw raw, const char *mnem, SHAddrHelper modes[])
Check whether raw and instruction to be formed using mnem and modes will be equivalent.
static char * sh_op_space_params(const char *buffer)
Replace all the commas outside operands with spaces (i.e. "space out" the operands)
static ut64 sh_op_movl_param_bits(const char *reg_direct, const char *reg_disp_indirect)
Special assembler functions for the operands of "weird" MOVL instruction.
static ut32 sh_op_param_bits(SHParamBuilder shb, const char *param, SHScaling scaling, ut64 pc)
Get the opcode bits corresponding to param, scaling, pc and addressing mode (shb.mode) This function ...
struct sh_addr_dissassembler_helper_t SHAddrHelper
RZ_IPI ut16 sh_assembler(RZ_NONNULL const char *buffer, ut64 pc, RZ_NULLABLE bool *success)
Assemble instruction from SuperH-4 ISA FPU instructions not implemented yet.
const SHOpRaw sh_op_lookup[]
static SHAddrHelper sh_op_get_addr_mode(const char *param)
Get the addressing mode being used in param.
enum sh_scaling_t SHScaling
enum sh_addr_mode_t SHAddrMode
enum sh_register_index_t SHRegisterIndex
static const ut8 sh_scaling_size[]
@ SH_IMM_S
8-bit immediate value (sign-extended)
@ SH_REG_INDIRECT_DISP
register indirect with displacement
@ SH_REG_INDIRECT_INDEXED
indexed register indirect
@ SH_REG_INDIRECT_I
register indirect with post-increment
@ SH_IMM_U
8-bit immediate value (zero-extended)
@ SH_REG_INDIRECT_D
register indirect with pre-decrement
@ SH_GBR_INDIRECT_INDEXED
const char * str_mnem
string mnemonic
SHScaling scaling
scaling for the opcode
SHParamBuilder param_builder[2]
param builders for the params
ut16 mask
mask for opcode to mask out param bits
ut8 start
start bit of the param (assuming little-endian)
SHAddrMode mode
addressing mode being used
st8 bits
bits to be read (-1, if you want this to be inferred from mode)
struct sh_param_builder_addr_t addr
bool is_param
whether a param was directly passed
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode dd[]