Question

Locked

Simulating MIPS instruction execution in java

By mayortendi ·
Below is a java code for a class in a project to simulate MIPS instruction execution. I pretty much have most of all else but i am stuck on this one. Please read the commentary and help me figure out the code i need to put in for the decoder function. I need to implement method decode() in class Utils. This decodes hexadecimal
command (0xafb2001c) into real command (add $1, $2, $3). Please give commentary if possible


package simulator;

/**
* Class Utils contains the various utility functions used by other classes. The most
* import one is decode(String hexcommand), which turns commands in hexadecimal into
* readable format.
*
*/
public class Utils {
public static String strip0x(String s){
if (s.startsWith("0x")) return s.substring(2);
return s;
}

public static int parseNumber(String s){
//System.out.println("Trying to parse:"+s);
if (s.startsWith("0x")) return Integer.valueOf(s.substring(2),16);
return Integer.valueOf(s,10);
}

/**
* Given a hexadecimal command, return a command in readable assembly language.
* @param hexcommand
* @return
*/
public static String decoder(String hexcommand){
String command="";

return command;
}
}

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Share your knowledge
Back to Software Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums