Skip to content

MIPS: add/fix support for "rdhwr" instruction  #1780

@kittennbfive

Description

@kittennbfive

Hello,

the rdhwr-instruction is currently not disassembled by Capstone, but it is disassembled by mips-linux-gnu-objdump.

Testcase:

#include <stdio.h>
#include <inttypes.h>

#include <capstone/capstone.h>

#define CODE "\x3B\x08\x06\x7C"

/*
MIPS32LE

output from GCC objdump:
7c06083b 	rdhwr	a2,hwr_synci_step

output from Capstone:
(error)
*/

int main(void)
{
	csh handle;
	cs_insn *insn;
	size_t count;

	if (cs_open(CS_ARCH_MIPS, CS_MODE_MIPS32+CS_MODE_LITTLE_ENDIAN, &handle) != CS_ERR_OK)
		return -1;
	count = cs_disasm(handle, CODE, sizeof(CODE)-1, 0x1000, 0, &insn);
	if (count > 0) {
		size_t j;
		for (j = 0; j < count; j++) {
			printf("0x%"PRIx64":\t%s\t\t%s\n", insn[j].address, insn[j].mnemonic,
					insn[j].op_str);
		}

		cs_free(insn, count);
	} else
		printf("ERROR: Failed to disassemble given code!\n");

	cs_close(&handle);

    return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions