Files

41 lines
965 B
C
Raw Permalink Normal View History

2024-01-28 12:16:11 -03:00
/* SPDX-FileCopyrightText: © 2022-2024 Decompollaborate */
2022-06-03 20:19:58 -04:00
/* SPDX-License-Identifier: MIT */
#include "instructions/RabbitizerInstruction.h"
2022-06-03 20:19:58 -04:00
#include <assert.h>
#include <stdio.h>
2022-07-10 16:04:39 -04:00
#include <string.h>
#include <stdlib.h>
2022-06-03 20:19:58 -04:00
2022-06-03 20:19:58 -04:00
int main() {
2022-07-03 19:28:13 -04:00
uint32_t word;
RabbitizerInstruction instr;
char *buffer;
2022-07-03 19:28:13 -04:00
int extraLJust = 5;
2022-10-09 21:59:33 -03:00
size_t bufferSize;
size_t disassembledSize;
2022-07-03 19:28:13 -04:00
2022-10-09 21:59:33 -03:00
word = 0x8D4A7E18; // lw
//word = 0x00004010; // mfhi
2022-06-03 20:19:58 -04:00
RabbitizerInstruction_init(&instr, word, 0x80000000);
2022-06-03 20:19:58 -04:00
RabbitizerInstruction_processUniqueId(&instr);
2022-06-04 01:24:59 -04:00
2022-10-09 21:59:33 -03:00
bufferSize = RabbitizerInstruction_getSizeForBuffer(&instr, 0, extraLJust);
buffer = malloc(bufferSize + 1);
assert(buffer != NULL);
2022-06-03 20:19:58 -04:00
2022-10-09 21:59:33 -03:00
disassembledSize = RabbitizerInstruction_disassemble(&instr, buffer, NULL, 0, extraLJust);
assert(disassembledSize <= bufferSize);
2022-06-03 20:19:58 -04:00
printf("%08X: %s\n", word, buffer);
free(buffer);
RabbitizerInstruction_destroy(&instr);
2022-06-03 20:19:58 -04:00
return 0;
}