<?php

//hex string to integer, allowing 2's complement
function hexstr_int($hexStr) {
	return (int) bindec(sprint_f("%032b",hexdec($hexStr)));
}
//hex string to bin, allowing 2's complement
function hexstr_bin($hexStr) {
	return sprintf("%032b",hexdec($hexStr));
}
//Zero-Extends a 32-bit-length binary string
function bin32($bin) {
	return sprintf("%032s",$bin);
}

///////// Experiments
$output .= 
""
.'sprintf("%d", "1111101")'
.sprintf("%d", "1111101")
."\n"

;

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title>MIPhpS: Online MIPS simulator</title>
	<link rel="stylesheet" type="text/css" href="mips.css" />
</head>
<body>
<h1>Testing Base & Number Related Things in PHP</h1>

<?php
if (!array_key_exists('source', $_GET)) {

?>
<h2>Alan Hogan&rsquo;s project for CSE 230 at ASU</h2>

<?php if(strlen(trim($debug))) { ?>

<div style="border: 1px solid #c00; padding: .5em;"><?php print nl2br(htmlentities($debug)); ?></div>
<?php
}

if (strlen($output)) {
	print '<h3>Output</h3><div class="code">'.nl2br(htmlentities($output)).'</div>';
}
?>	


</body>
</html>
