This is a prototype of the Mips assembler writen by Jenelle levenstein

Please enter you MIPS code. "; ?>


"; return -1; } /* $data is a two D array that will hold the data after parsing the fields of $data mirror the fields of the database we will be using */ // values in the $data arrary will contain "" if data is invalid $data = array( array( "mips" =>"", // used to store unparsed mips instr "label" =>"", // used to store the label preceding instr "instr" =>"", // used to store instr type "args" =>"", // stores the args to instr in a comma delemited list "comment"=>"", // stores comment of function "binary" =>"", // stores bianry code "goto" =>"", // stores label atatched to branch instr's "instrNum" =>""// stores the inst number on lines that have mips instructions ) ); /* loops through the array of $code and populates the $data array for branch instruction the $binary field wil be "" */ $instrNum =0; $err = 0; for($i=0; $i". $err = -1; } else { $offset = $destInstrNum - $srcInstrNum -1; // echo "offset = $offset "; $oldBinary= $data[$i]["binary"]; $data[$i]["binary"] =$oldBinary.toBinary($offset,16); } } } } if($err == 0) { // outputs machine code echo "Machine Language code
"; for($i=0; $i< sizeof($code); $i++) { if($data[$i]["binary"] != "") echo $data[$i]["binary"]."
"; } } } ?>