0

When you have a code loaded on mips, you can dump that code in different formats, like: ASCII Text, Binary, Binary Text, Hexadecimal, etc...

How could I read a binary input and then convert it to assembly ?
Can't find any function/method to help me with this...
I know we usually show some code and then get some help but besides of receiving an input I have no idea how to start this.

PlayHardGoPro
  • 2,791
  • 10
  • 51
  • 90
  • 2
    Assembly language doesn't have any kind of built-in introspection or disassembly functionality. You have to read instruction words, decode them, and output text from tables. Writing a disassembler in assembly language is of course possible (with or without the help of a compiler to generate that asm), but I wouldn't recommend it. C or C++ would be easier. Although MIPS is so simple to decode that it wouldn't be hard to do it in asm. – Peter Cordes Oct 07 '17 at 05:00
  • 1
    slightly related: https://stackoverflow.com/questions/7057175/question-regarding-assembly-and-computer-programs, re: understanding machine code / binary instructions. – Peter Cordes Oct 07 '17 at 05:04
  • 3
    I'm sure this has been asked before, but I'm not finding any good duplicates. Anyway, the answer is "the same as you would in C". Open files (with system calls), read binary bytes, process data, write text bytes. – Peter Cordes Oct 07 '17 at 05:19
  • Ok but as mentioned above. There is no built-in function to help process that adata. How is it possible to convert Bynary to Assembly without help? How to identify it while converting. – PlayHardGoPro Oct 07 '17 at 20:02
  • 2
    See https://stackoverflow.com/questions/924303/how-to-write-a-disassembler. That's asking about x86; MIPS is easier to decode. http://www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html shows the encodings for each instruction. – Peter Cordes Oct 07 '17 at 20:13
  • 2
    Of course, there are [MIPS disassemblers already](https://stackoverflow.com/questions/9916130/how-do-i-disassemble-raw-mips-code), so you could look at their source code. – Peter Cordes Oct 07 '17 at 20:16
  • As it's a different topic. Cant make it work https://stackoverflow.com/questions/46627968/reading-and-printing-content-from-a-txt-file-using-mips-assembly – PlayHardGoPro Oct 08 '17 at 05:55

0 Answers0