Help with disassembling MIPS32 bit instructions Having troub
Help with disassembling MIPS-32 bit instructions
Having trouble disassembling. I know opcode is usually the first 6 bits and then that determines the rest of instruction whether valid or not.
Need help filling in blanks.
| Address | Instruction | Instruction type (I,R,J) | Assembly Language Instruction | Mistakes in formatted instruction (if any) |
| 0040000C | BC812DE2 | |||
| 004000B8 | 1921A0BF | |||
| 004000A8 | CC6C1F45 | |||
| 0040001C | E3AD303B | |||
| 0040009C | 86920C3F | |||
| 00400030 | AAB71AD1 | |||
| 0040008C | 00000008 | |||
| 00400040 | BBF2AF57 | |||
| 0040007C | 0F637553 | |||
| 00400058 | A2538BF2 |
Solution
import java.awt.Color;
import java.util.Comparator;
/**
* a straightforward red-black tree category.
*/
public category RedBlackTree extends BinarySearchTree Associate in Nursing empty RedBlackTree which will solely settle for Comparables as
* items.
*/
public RedBlackTree()
/**
* Constructs Associate in Nursing empty RedBlackTree that orders its things in keeping with the
* given comparator.
*/
public RedBlackTree(Comparator c)
/**
* The nodes during a red-black tree store a color beside the particular information
* within the node.
*/
category Node extends LinkedBinaryTreeNode
}
/**
* Adds one information item to the tree. If there\'s already Associate in Nursing item within the
* tree that compares up to the item being inserted, it\'s \"overwritten\"
* by the new item. Overrides BinarySearchTree.add as a result of the tree must
* be adjusted when insertion.
*/
public void add(Object data)
BinaryTreeNode n = root;
whereas (true) else if (comparisonResult < 0)
n = n.getLeft();
} else zero
if (n.getRight() == null)
n = n.getRight();
}
}
}
/**
* Removes the node containing the given price. will nothing if there\'s no
* such node.
*/
public void remove(Object data) else if (node.getLeft() != null && node.getRight() != null) 2 kids, Copy forerunner information in.
BinaryTreeNode forerunner = predecessor(node);
node.setData(predecessor.getData());
node = (Node) predecessor;
}
// At this time node has zero or one kid
Node pullUp = leftOf(node) == null ? rightOf(node) : leftOf(node);
if (pullUp != null) regulate if pullUp could be a double black.
if (node == root) else if (node.getParent().getLeft() == node) else
if (isBlack(node))
} else if (node == root) to drag up once deleting a root means that we have a tendency to empty the tree
setRoot(null);
} else lookout
if (isBlack(node))
node.removeFromParent();
}
}
/**
* Classic formula for fixing up a tree when inserting a node.
*/
personal void adjustAfterInsertion(Node n) issues, if they exist
if (n != null && n != root && isRed(parentOf(n))) to ascertain if additional work
// needed
if (isRed(siblingOf(parentOf(n))))
// Step 2b: reconstitute for a parent United Nations agency is that the left kid of the
// forebear. this may need one right rotation if n is
// also
// a left kid, or a left-right rotation otherwise.
else if (parentOf(n) == leftOf(grandparentOf(n)))
setColor(parentOf(n), Color.black);
setColor(grandparentOf(n), Color.red);
rotateRight(grandparentOf(n));
}
// Step 2c: reconstitute for a parent United Nations agency is that the right kid of the
// forebear. this may need one left rotation if n is
// also
// a right kid, or a right-left rotation otherwise.
else if (parentOf(n) == rightOf(grandparentOf(n)))
setColor(parentOf(n), Color.black);
setColor(grandparentOf(n), Color.red);
rotateLeft(grandparentOf(n));
}
}
// Step 3: Color the foundation black
setColor((Node) root, Color.black);
}
/**
* Classic formula for fixing up a tree when removing a node; the
* parameter to the present technique is that the node that was force up to wherever the
* removed node was.
*/
personal void adjustAfterRemoval(Node n) {
whereas (n != root && isBlack(n)) {
if (n == leftOf(parentOf(n))) {
// force up node could be a left kid
Node relative = rightOf(parentOf(n));
if (isRed(sibling)) {
setColor(sibling, Color.black);
setColor(parentOf(n), Color.red);
rotateLeft(parentOf(n));
relative = rightOf(parentOf(n));
}
if (isBlack(leftOf(sibling)) && isBlack(rightOf(sibling))) else {
if (isBlack(rightOf(sibling))) {
setColor(leftOf(sibling), Color.black);
setColor(sibling, Color.red);
rotateRight(sibling);
relative = rightOf(parentOf(n));
}
setColor(sibling, colorOf(parentOf(n)));
setColor(parentOf(n), Color.black);
setColor(rightOf(sibling), Color.black);
rotateLeft(parentOf(n));
n = (Node) root;
}
} else {
// force up node could be a right kid
Node relative = leftOf(parentOf(n));
if (isRed(sibling)) {
setColor(sibling, Color.black);
setColor(parentOf(n), Color.red);
rotateRight(parentOf(n));
relative = leftOf(parentOf(n));
}
if (isBlack(leftOf(sibling)) && isBlack(rightOf(sibling))) else {
if (isBlack(leftOf(sibling))) {
setColor(rightOf(sibling), Color.black);
setColor(sibling, Color.red);
rotateLeft(sibling);
relative = leftOf(parentOf(n));
}
setColor(sibling, colorOf(parentOf(n)));
setColor(parentOf(n), Color.black);
setColor(leftOf(sibling), Color.black);
rotateRight(parentOf(n));
n = (Node) root;
}
}
}
setColor(n, Color.black);
}
// the subsequent helpers dramatically modify the code by obtaining
// all the null pointer sorting out of the adjustment strategies.
personal Color colorOf(Node n) come back n == null ? Color.black : n.color;
}
personal mathematician isRed(Node n) come back n != null && colorOf(n) == Color.red;
}
personal mathematician isBlack(Node n) come back n == null || colorOf(n) == Color.black;
}
personal void setColor(Node n, Color c)
personal Node parentOf(Node n) come back n == null ? null : (Node) n.getParent();
}
personal Node grandparentOf(Node n) come back (n == null || n.getParent() == null) ? null : (Node) n
.getParent().getParent();
}
personal Node siblingOf(Node n) come back (n == null || n.getParent() == null) ? null : (n == n
.getParent().getLeft()) ? (Node) n.getParent().getRight()
: (Node) n.getParent().getLeft();
}
personal Node leftOf(Node n) come back n == null ? null : (Node) n.getLeft();
}
personal Node rightOf(Node n) come back n == null ? null : (Node) n.getRight();
}
}



