sm64

A Super Mario 64 decompilation
Log | Files | Refs | README | LICENSE

test.c (960B)


      1 /* SPDX-FileCopyrightText: © 2022 Decompollaborate */
      2 /* SPDX-License-Identifier: MIT */
      3 
      4 #include "instructions/RabbitizerInstruction.h"
      5 
      6 #include <assert.h>
      7 #include <stdio.h>
      8 #include <string.h>
      9 #include <stdlib.h>
     10 
     11 
     12 int main() {
     13     uint32_t word;
     14     RabbitizerInstruction instr;
     15     char *buffer;
     16     int extraLJust = 5;
     17     size_t bufferSize;
     18     size_t disassembledSize;
     19 
     20     word = 0x8D4A7E18; // lw
     21     //word = 0x00004010; // mfhi
     22 
     23     RabbitizerInstruction_init(&instr, word, 0x80000000);
     24 
     25     RabbitizerInstruction_processUniqueId(&instr);
     26 
     27     bufferSize = RabbitizerInstruction_getSizeForBuffer(&instr, 0, extraLJust);
     28     buffer = malloc(bufferSize + 1);
     29     assert(buffer != NULL);
     30 
     31     disassembledSize = RabbitizerInstruction_disassemble(&instr, buffer, NULL, 0, extraLJust);
     32     assert(disassembledSize <= bufferSize);
     33 
     34     printf("%08X: %s\n", word, buffer);
     35 
     36     free(buffer);
     37     RabbitizerInstruction_destroy(&instr);
     38 
     39     return 0;
     40 }