rabbitizer/test.c

37 lines
817 B
C
Raw Normal View History

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