assembly language emulator

manual
introduction
please install your own personal copy of this emulator

if you want to make a tax-deductible donation to the StarTree107 Foundation to support this educational work, contact Dr. Barry at 949-675-5778

memoryinputstring is ".$memoryinputstring."*"; if ( $memoryinputstring ) /* test for anything input */ { $memory = array(); /* begin array */ $memoryinputstring = trim($memoryinputstring); /* eliminate white space at beginning and end of line */ while ($memoryinputstring != '') { $firstspace = strpos($memoryinputstring, ' '); /* find first space, if any */ $keypart = substr($memoryinputstring,0,$firstspace); /* get token including marker */ $memoryinputstring = trim($memoryinputstring); /* eliminate white space at beginning and end of line */ $keypart = trim($keypart); /* eliminate white space at beginning and end of line */ $restofstring = substr($memoryinputstring,$firstspace); $memoryinputstring = trim($restofstring); /* assuming that memory must always be one byte long */ $valuepart = substr($memoryinputstring,0,2); /* get token including marker */ $remaininglength = strlen($memoryinputstring); /* find current length */ $restofstring = substr($memoryinputstring,2); /* chop off first two characters */ $memoryinputstring = trim($restofstring); $keypart = (string)$keypart; $valuepart = (string)$valuepart; /* echo "
keypart is ".$keypart; echo "
valuepart is ".$valuepart; echo "
rest of memoryinputstring is ".$memoryinputstring."*"; */ $memory[(string)$keypart] = (string)$valuepart; /* $memory = array($keypart => $valuepart); */ /* if ( is_array( $memory ) ) { print_r($memory); } else { echo "
memory is not an array"; } */ $remaininglength = strlen($memoryinputstring); /* find current length */ if ( $remaininglength > 2 ) { } else { break; } } /* end while */ } /* end if */ $displaycodememoryflag = FALSE; /*******************************************/ /* get code memory string and then turn into 3-dimensional array */ /*******************************************/ echo "
codeinputstring is ".$codeinputstring."*"; /* echo "
p0codesize is ".$p0codesize; */ if ( $codeinputstring ) /* test for anything input */ { $codeinputstring = trim($codeinputstring); /* eliminate white space at beginning and end of line */ while ($codeinputstring != '') { $firstspace = strpos($codeinputstring, ' '); /* find first space, if any */ $codememorypointer = substr($codeinputstring,0,$firstspace); /* get first token, the memory location */ $codememorypointer = trim($codememorypointer); /* eliminate white space at beginning and end of variable */ $restofstring = substr($codeinputstring,$firstspace); $codeinputstring = trim($restofstring); /* eliminate white space at beginning and end of line */ $firstspace = strpos($codeinputstring, ' '); /* find new first space, if any */ $codearray[$codememorypointer][LABELPOS] = substr($codeinputstring,0,$firstspace); /* get next token, the label */ $restofstring = substr($codeinputstring,$firstspace); $codeinputstring = trim($restofstring); /* eliminate white space at beginning and end of line */ $firstspace = strpos($codeinputstring, ' '); /* find new first space, if any */ $storedtokencount = substr($codeinputstring,0,$firstspace); /* get next token, the token count */ $codearray[$codememorypointer][TOKENCOUNTPOS] = $storedtokencount; $restofstring = substr($codeinputstring,$firstspace); $codeinputstring = trim($restofstring); /* eliminate white space at beginning and end of line */ for ($loopvariable = 1; $loopvariable <= $storedtokencount; $loopvariable++) { $firstspace = strpos($codeinputstring, ' '); /* find new first space, if any */ if ( $firstspace == 0 ) { $codearray[$codememorypointer][TOKENCOUNTPOS+$loopvariable] = $codeinputstring; /* get last item */ } else { $codearray[$codememorypointer][TOKENCOUNTPOS+$loopvariable] = substr($codeinputstring,0,$firstspace); /* get next token, an operation or operand */ $restofstring = substr($codeinputstring,$firstspace); $codeinputstring = trim($restofstring); /* eliminate white space at beginning and end of line */ } } /* place current tokens into $codearray[PC][token positions] */ /* debugging code */ /* echo "
stored code array is ".$codememorypointer." ".$codearray[$codememorypointer][LABELPOS]." ".$codearray[$codememorypointer][TOKENCOUNTPOS]." ".$codearray[$codememorypointer][COMMANDPOS]." ".$codearray[$codememorypointer][COMMANDPOS+1]." ".$codearray[$codememorypointer][COMMANDPOS+2]." ".$codearray[$codememorypointer][COMMANDPOS+3]."*"; echo "
codememorypointer is ".$codememorypointer." and p0codesize is ".$p0codesize;*/ if ( $codememorypointer >= ($p0codesize - 1) ) { break; /* to prevent infinite loop */ } } } /* to skip over functions search for "CONTINUATION OF WORKING CODE" */ /******************************/ /* FUNCTIONS */ /******************************/ /******************************/ /* FUNCTION: ExtractByte() */ /* input: $originalvalue of item */ /* input: $bytenumber where to insert */ /* zero is least significant byte */ /* output: chosen byte */ /******************************/ function ExtractByte($originalvalue, $bytenumber) { $stringlength = strlen($originalvalue); /* find current length */ if ( $stringlength > (2 * $bytenumber) ) { /* left pad string with zeros */ } $tempstring = $originalvalue; $bytelocation = $stringlength - ( ( 2 * $bytenumber ) + 2); $tempstring = substr($originalvalue,$bytelocation,2); return $tempstring; } /******************************/ /* FUNCTION: InsertByte() */ /* input: $originalvalue of item */ /* input: $insertedbyte to put in item */ /* input: $bytenumber where to insert */ /* zero is least significant byte */ /* output: changed item (w/ new byte) */ /******************************/ function InsertByte($originalvalue, $insertedbyte, $bytenumber) { $stringlength = strlen($originalvalue); /* find current length */ if ( $stringlength > (2 * $bytenumber) ) { /* left pad string with zeros */ } $tempstring = $originalvalue; $bytelocation = $stringlength - ( ( 2 * $bytenumber ) + 2); $firstpart = substr($originalvalue,0,$bytelocation); /* second part is $insertedbyte */ $thirdpart = substr($originalvalue,$bytelocation+2); $tempstring = $firstpart.$insertedbyte.$thirdpart; /* concatonate */ return $tempstring; } /******************************/ /* FUNCTION: HexDigitToBits() */ /* input: $originalvalue of item */ /* should be a single character */ /* output: bit string */ /******************************/ function HexDigitToBits($originalvalue) { $tempstring = strtoupper( $originalvalue) ; /* just in case acceptable lower case letter */ /* add check for out of bounds character or more than one character */ switch ( $tempstring ) { case "0" : return '0000'; break; case "1" : return '0001'; break; case "2" : return '0010'; break; case "3" : return '0011'; break; case "4" : return '0100'; break; case "5" : return '0101'; break; case "6" : return '0110'; break; case "7" : return '0111'; break; case "8" : return '1000'; break; case "9" : return '1001'; break; case "A" : return '1010'; break; case "B" : return '1011'; break; case "C" : return '1100'; break; case "D" : return '1101'; break; case "E" : return '1101'; break; case "F" : return '1111'; break; } /* end of switch */ /* $tempstring = $originalvalue; $bytelocation = $stringlength - ( ( 2 * $bytenumber ) + 2); $tempstring = substr($originalvalue,$bytelocation,2); */ return '0000'; /* if anything went wrong, return the bit string for zero */ } /******************************/ /* FUNCTION: BitstoHexDigit() */ /* input: $originalvalue of item */ /* should be four bit bit string */ /* output: single hex digit */ /******************************/ function BitstoHexDigit($originalvalue) { /* add check for really a bit string */ switch ( $originalvalue ) { case "0000" : return '0'; break; case "0001" : return '1'; break; case "0010" : return '2'; break; case "0011" : return '3'; break; case "0100" : return '4'; break; case "0101" : return '5'; break; case "0110" : return '6'; break; case "0111" : return '7'; break; case "1000" : return '8'; break; case "1001" : return '9'; break; case "1010" : return 'A'; break; case "1011" : return 'B'; break; case "1100" : return 'C'; break; case "1101" : return 'D'; break; case "1101" : return 'E'; break; case "1111" : return 'F'; break; } /* end of switch */ return '0'; /* if anything went wrong, return the hex digit for zero */ } /******************************/ /* FUNCTION: OpNot() */ /* input: $originalvalue */ /* bit string of any length */ /* output: bit string */ /* with logical not on every bit */ /******************************/ function OpNot($originalvalue) { $stringlength = strlen($originalvalue); /* find bit string length length */ $newbitstring = ''; for ($loopvariable = 0; $loopvariable < $stringlength; $loopvariable += 1) { $tempbit = substr($originalvalue,$loopvariable,1); if ( $tempbit == 0 ) { $tempbit = 1; } else { $tempbit = 0; } $newbitstring = $newbitstring.$tempbit; } /* end for loop */ return $newbitstring; } /******************************/ /* FUNCTION: CreateBitArray() */ /* input: $originalvalue of item */ /* input: $bytenumber where to insert */ /* zero is least significant byte */ /* output: chosen byte */ /******************************/ function CreateBitArray($originalvalue, $numbytes) { $locationmarker = 0; /* add check for illegal number of bytes */ $newstring = base_convert($originalvalue, 16, 2); /* turn original hex into bit string */ $reversedstring = strrev($newstring); /* reverse order of bits so low order bit is bit zero */ $bitarray = str_split($reversedstring); /* turn into bit array */ return $bitarray; } /******************************/ /* FUNCTION: LoadRegister() */ /* input: $registername of register */ /* input: $registervalue to put in register */ /* output: side effects */ /******************************/ function LoadRegister($registername, $registervalue) { global $currentprocessor; switch ( $registername ) { case "A" : global $p0acc; global $p1acc; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0acc = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1acc = $registervalue; } break; case "ACC" : global $p0acc; global $p1acc; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0acc = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1acc = $registervalue; } break; case "AP" : global $p0AP; global $p1AP; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0AP = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1AP = $registervalue; } break; case "A0" : global $p0A0; global $p1A0; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0A0 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1A0 = $registervalue; } break; case "A1" : global $p0A1; global $p1A1; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0A1 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1A1 = $registervalue; } break; case "A2" : global $p0A2; global $p1A2; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0A2 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1A2 = $registervalue; } break; case "A3" : global $p0A3; global $p1A3; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0A3 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1A3 = $registervalue; } break; case "A4" : global $p0A4; global $p1A4; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0A4 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1A4 = $registervalue; } break; case "A5" : global $p0A5; global $p1A5; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0A5 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1A5 = $registervalue; } break; case "A6" : global $p0A6; global $p1A6; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0A6 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1A6 = $registervalue; } break; case "A7" : global $p0A7; global $p1A7; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0A7 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1A7 = $registervalue; } break; case "B" : global $p0b; global $p1b; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0b = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1b = $registervalue; } break; case "C" : global $p0c; global $p1c; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0c = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1c = $registervalue; } break; case "COUNT" : global $p0count; global $p1count; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0count = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1count = $registervalue; } break; case "D" : global $p0d; global $p1d; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0d = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1d = $registervalue; } break; case "D0" : global $p0D0; global $p1D0; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0D0 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1D0 = $registervalue; } break; case "D1" : global $p0D1; global $p1D1; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0D1 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1D1 = $registervalue; } break; case "D2" : global $p0D2; global $p1D2; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0D2 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1D2 = $registervalue; } break; case "D3" : global $p0D3; global $p1D3; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0D3 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1D3 = $registervalue; } break; case "D4" : global $p0D4; global $p1D4; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0D4 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1D4 = $registervalue; } break; case "D5" : global $p0D5; global $p1D5; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0D5 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1D5 = $registervalue; } break; case "D6" : global $p0D6; global $p1D6; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0D6 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1D6 = $registervalue; } break; case "D7" : global $p0D7; global $p1D7; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0D7 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1D7 = $registervalue; } break; case "E" : global $p0e; global $p1e; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0e = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1e = $registervalue; } break; case "FP" : global $p0FP; global $p1FP; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0FP = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1FP = $registervalue; } break; case "F0" : global $p0F0; global $p1H0; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F0 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F0 = $registervalue; } break; case "F1" : global $p0F1; global $p1HF1; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F1 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F1 = $registervalue; } break; case "F2" : global $p0F2; global $p1F2; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F2 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F2 = $registervalue; } break; case "F3" : global $p0F3; global $p1F3; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F3 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F3 = $registervalue; } break; case "F4" : global $p0F4; global $p1F4; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F4 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F4 = $registervalue; } break; case "F5" : global $p0F5; global $p1F5; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F5 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F5 = $registervalue; } break; case "F6" : global $p0F6; global $p1H6; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F6 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F6 = $registervalue; } break; case "F7" : global $p0F7; global $p1F7; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F7 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F7 = $registervalue; } break; case "F8" : global $p0F8; global $p1F8; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F8 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F8 = $registervalue; } break; case "F9" : global $p0F9; global $p1F9; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F9 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F9 = $registervalue; } break; case "F10" : global $p0F10; global $p1F10; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F10 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F10 = $registervalue; } break; case "F11" : global $p0F11; global $p1F11; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F11 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F11 = $registervalue; } break; case "F12" : global $p0F12; global $p1F12; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F12 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F12 = $registervalue; } break; case "F13" : global $p0F13; global $p1F13; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F13 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F13 = $registervalue; } break; case "F14" : global $p0F14; global $p1F14; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F14 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F14 = $registervalue; } break; case "F15" : global $p0F15; global $p1F15; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F15 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F15 = $registervalue; } break; case "F16" : global $p0F16; global $p1F16; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F16 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F16 = $registervalue; } break; case "F17" : global $p0F17; global $p1F17; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F17 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F17 = $registervalue; } break; case "F18" : global $p0F18; global $p1F18; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F18 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F18 = $registervalue; } break; case "F19" : global $p0F19; global $p1F19; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F19 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F19 = $registervalue; } break; case "F20" : global $p0F20; global $p1F20; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F20 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F20 = $registervalue; } break; case "F21" : global $p0F21; global $p1F21; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F21 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F21 = $registervalue; } break; case "F22" : global $p0F22; global $p1F22; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F22 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F22 = $registervalue; } break; case "F23" : global $p0F23; global $p1F23; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F23 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F23 = $registervalue; } break; case "F24" : global $p0F24; global $p1F24; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F24 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F24 = $registervalue; } break; case "F25" : global $p0F25; global $p1F25; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F25 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F25 = $registervalue; } break; case "F26" : global $p0F26; global $p1F26; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F26 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F26 = $registervalue; } break; case "F27" : global $p0F27; global $p1F27; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F27 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F27 = $registervalue; } break; case "F28" : global $p0F28; global $p1F28; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F28 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F28 = $registervalue; } break; case "F29" : global $p0F29; global $p1F29; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F29 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F29 = $registervalue; } break; case "F30" : global $p0F30; global $p1F30; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F30 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F30 = $registervalue; } break; case "F31" : global $p0F31; global $p1F31; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0F31 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F31 = $registervalue; } break; case "HL" : global $p0HL; global $p1HL; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0HL = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1HL = $registervalue; } break; case "INDEX" : global $p0indexx; global $p1indexx; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0indexx = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1indexx = $registervalue; } break; case "INDEX1" : global $p0index1; global $p1index1; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0index1 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1index1 = $registervalue; } break; case "INDEX2" : global $p0index2; global $p1index2; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0index2 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1index2 = $registervalue; } break; case "INDEX3" : global $p0index3; global $p1index3; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0index3 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1index3 = $registervalue; } break; case "INDEX4" : global $p0index4; global $p1index4; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0index4 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1index4 = $registervalue; } break; case "INDEX5" : global $p0index5; global $p1index5; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0index5 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1index5 = $registervalue; } break; case "INDEX6" : global $p0index6; global $p1index6; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0index6 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1index6 = $registervalue; } break; case "JUMP" : global $p0jump; global $p1jump; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0jump = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1jump = $registervalue; } break; case "LINK" : global $p0link; global $p1link; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0link = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1link = $registervalue; } break; case "L0" : global $p0L0; global $p1L0; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L0 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L0 = $registervalue; } break; case "L1" : global $p0L1; global $p1L1; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L1 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L1 = $registervalue; } break; case "L2" : global $p0L2; global $p1L2; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L2 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L2 = $registervalue; } break; case "L3" : global $p0L3; global $p1L3; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L3 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L3 = $registervalue; } break; case "L4" : global $p0L4; global $p1L4; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L4 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L4 = $registervalue; } break; case "L5" : global $p0L5; global $p1L5; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L5 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L5 = $registervalue; } break; case "L6" : global $p0L6; global $p1L6; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L6 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L6 = $registervalue; } break; case "L7" : global $p0L7; global $p1L7; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L7 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L7 = $registervalue; } break; case "L8" : global $p0L8; global $p1L8; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L8 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L8 = $registervalue; } break; case "L9" : global $p0L9; global $p1L9; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L9 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L9 = $registervalue; } break; case "L10" : global $p0L10; global $p1L10; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L10 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L10 = $registervalue; } break; case "L11" : global $p0L11; global $p1L11; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L11 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L11 = $registervalue; } break; case "L12" : global $p0L12; global $p1L12; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L12 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L12 = $registervalue; } break; case "L13" : global $p0L13; global $p1L13; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L14 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L14 = $registervalue; } break; case "L15" : global $p0L15; global $p1L15; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L15 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L15 = $registervalue; } break; case "L16" : global $p0L16; global $p1L16; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L16 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L16 = $registervalue; } break; case "L17" : global $p0L17; global $p1L17; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L17 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L17 = $registervalue; } break; case "L18" : global $p0L18; global $p1L18; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L18 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L18 = $registervalue; } break; case "L19" : global $p0L19; global $p1L19; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L19 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L19 = $registervalue; } break; case "L20" : global $p0L20; global $p1L20; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L20 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L20 = $registervalue; } break; case "L21" : global $p0L21; global $p1L21; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L21 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L21 = $registervalue; } break; case "L22" : global $p0L22; global $p1L22; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L22 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L22 = $registervalue; } break; case "L23" : global $p0L23; global $p1L23; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L23 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L23 = $registervalue; } break; case "L24" : global $p0L24; global $p1L24; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L24 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L24 = $registervalue; } break; case "L25" : global $p0L25; global $p1L25; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L25 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L25 = $registervalue; } break; case "L26" : global $p0L26; global $p1L26; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L26 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L26 = $registervalue; } break; case "L27" : global $p0L27; global $p1L27; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L27 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L27 = $registervalue; } break; case "L28" : global $p0L28; global $p1L28; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L28 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L28 = $registervalue; } break; case "L29" : global $p0L29; global $p1L29; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L29 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L29 = $registervalue; } break; case "L30" : global $p0L30; global $p1L30; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L30 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L30 = $registervalue; } break; case "L31" : global $p0L31; global $p1L31; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0L31 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1L31 = $registervalue; } break; case "PC" : global $p0PC; global $p1PC; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0PC = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1PC = $registervalue; } break; case "RP" : global $p0srp; global $p1srp; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0srp = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1srp = $registervalue; } break; case "R0" : global $p0R0; global $p1R0; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R0 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R0 = $registervalue; } break; case "R1" : global $p0R1; global $p1R1; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R1 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R1 = $registervalue; } break; case "R2" : global $p0R2; global $p1R2; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R2 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R2 = $registervalue; } break; case "R3" : global $p0R3; global $p1R3; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R3 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R3 = $registervalue; } break; case "R4" : global $p0R4; global $p1R4; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R4 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R4 = $registervalue; } break; case "R5" : global $p0R5; global $p1R5; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R5 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R5 = $registervalue; } break; case "R6" : global $p0R6; global $p1R6; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R6 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R6 = $registervalue; } break; case "R7" : global $p0R7; global $p1R7; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R7 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R7 = $registervalue; } break; case "R8" : global $p0R8; global $p1R8; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R8 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R8 = $registervalue; } break; case "R9" : global $p0R9; global $p1R9; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R9 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R9 = $registervalue; } break; case "R10" : global $p0R10; global $p1R10; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R10 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R10 = $registervalue; } break; case "R11" : global $p0R11; global $p1R11; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R11 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R11 = $registervalue; } break; case "R12" : global $p0R12; global $p1R12; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R12 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R12 = $registervalue; } break; case "R13" : global $p0R13; global $p1R13; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R13 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R13 = $registervalue; } break; case "R14" : global $p0R14; global $p1R14; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R14 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R14 = $registervalue; } break; case "R15" : global $p0R15; global $p1R15; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R15 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R15 = $registervalue; } break; case "R16" : global $p0R16; global $p1R16; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R16 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R16 = $registervalue; } break; case "R17" : global $p0R17; global $p1R17; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R17 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R17 = $registervalue; } break; case "R18" : global $p0R18; global $p1R18; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R18 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R18 = $registervalue; } break; case "R19" : global $p0R19; global $p1R19; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R19 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R19 = $registervalue; } break; case "R20" : global $p0R20; global $p1R20; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R20 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R20 = $registervalue; } break; case "R21" : global $p0R21; global $p1R21; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R21 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R21 = $registervalue; } break; case "R22" : global $p0R22; global $p1R22; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R22 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R22 = $registervalue; } break; case "R23" : global $p0R23; global $p1R23; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R23 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R23 = $registervalue; } break; case "R24" : global $p0R24; global $p1R24; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R24 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R24 = $registervalue; } break; case "R25" : global $p0R25; global $p1R25; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R25 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R25 = $registervalue; } break; case "R26" : global $p0R26; global $p1R26; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R26 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R26 = $registervalue; } break; case "R27" : global $p0R27; global $p1R27; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R27 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R27 = $registervalue; } break; case "R28" : global $p0R28; global $p1R28; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R28 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R28 = $registervalue; } break; case "R29" : global $p0R29; global $p1R29; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R29 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R29 = $registervalue; } break; case "R30" : global $p0R30; global $p1R30; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R30 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R30 = $registervalue; } break; case "R31" : global $p0R31; global $p1R31; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0R31 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1R31 = $registervalue; } break; case "SP" : global $p0SP; global $p1SP; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0SP = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1SP = $registervalue; } break; case "SRP" : global $p0srp; global $p1srp; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0srp = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1srp = $registervalue; } break; case "X" : global $p0indexx; global $p1indexx; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0indexx = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1indexx = $registervalue; } break; case "Y" : global $p0indexy; global $p1indexy; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p0indexy = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1indexy = $registervalue; } break; /* don't write to zero register, because it is always remains zero */ default : $errortype = "BAD REGISTER SPECIFICATION: ".$registername; } } /******************************/ /* FUNCTION: ValueFromRegister() */ /* input: $registername of register */ /* output: $value contents of register */ /******************************/ function ValueFromRegister($registername) { global $currentprocessor; switch ( $registername ) { case "A" : global $p0acc; global $p1acc; if ( $currentprocessor == 0 ) { return $p0acc; } else if ( $currentprocessor == 1 ) { return $p1acc; } break; case "ACC" : global $p0acc; global $p1acc; if ( $currentprocessor == 0 ) { return $p0acc; } else if ( $currentprocessor == 1 ) { return $p1acc; } break; case "AP" : global $p0AP; global $p1AP; if ( $currentprocessor == 0 ) { return $p0AP; } else if ( $currentprocessor == 1 ) { return $p1AP; } break; case "A0" : global $p0A0; global $p1A0; if ( $currentprocessor == 0 ) { return $p0A0; } else if ( $currentprocessor == 1 ) { return $p1A0; } break; case "A1" : global $p0A1; global $p1A1; if ( $currentprocessor == 0 ) { return $p0A1; } else if ( $currentprocessor == 1 ) { return $p1A1; } break; case "A2" : global $p0A2; global $p1A2; if ( $currentprocessor == 0 ) { return $p0A2; } else if ( $currentprocessor == 1 ) { return $p1A2; } break; case "A3" : global $p0A3; global $p1A3; if ( $currentprocessor == 0 ) { return $p0A3; } else if ( $currentprocessor == 1 ) { return $p1A3; } break; case "A4" : global $p0A4; global $p1A4; if ( $currentprocessor == 0 ) { return $p0A4; } else if ( $currentprocessor == 1 ) { return $p1A4; } break; case "A5" : global $p0A5; global $p1A5; if ( $currentprocessor == 0 ) { return $p0A5; } else if ( $currentprocessor == 1 ) { return $p1A5; } break; case "A6" : global $p0A6; global $p1A6; if ( $currentprocessor == 0 ) { return $p0A6; } else if ( $currentprocessor == 1 ) { return $p1A6; } break; case "A7" : global $p0A7; global $p1A7; if ( $currentprocessor == 0 ) { return $p0A7; } else if ( $currentprocessor == 1 ) { return $p1A7; } break; case "B" : global $p0B; global $p1B; if ( $currentprocessor == 0 ) { return $p0B; } else if ( $currentprocessor == 1 ) { return $p1B; } break; case "C" : global $p0C; global $p1C; if ( $currentprocessor == 0 ) { return $p0C; } else if ( $currentprocessor == 1 ) { return $p1C; } break; case "COUNT" : global $p0count; global $p1count; if ( $currentprocessor == 0 ) { return $p0count; } else if ( $currentprocessor == 1 ) { return $p1count; } break; case "D" : global $p0D; global $p1D; if ( $currentprocessor == 0 ) { return $p0D; } else if ( $currentprocessor == 1 ) { return $p1D; } break; case "D0" : global $p0D0; global $p1D0; if ( $currentprocessor == 0 ) { return $p0D0; } else if ( $currentprocessor == 1 ) { return $p1D0; } break; case "D1" : global $p0D1; global $p1D1; if ( $currentprocessor == 0 ) { return $p0D1; } else if ( $currentprocessor == 1 ) { return $p1D1; } break; case "D2" : global $p0D2; global $p1D2; if ( $currentprocessor == 0 ) { return $p0D2; } else if ( $currentprocessor == 1 ) { return $p1D2; } break; case "D3" : global $p0D3; global $p1D3; if ( $currentprocessor == 0 ) { return $p0D3; } else if ( $currentprocessor == 1 ) { return $p1D3; } break; case "D4" : global $p0D4; global $p1D4; if ( $currentprocessor == 0 ) { return $p0D4; } else if ( $currentprocessor == 1 ) { return $p1D4; } break; case "D5" : global $p0D5; global $p1D5; if ( $currentprocessor == 0 ) { return $p0D5; } else if ( $currentprocessor == 1 ) { return $p1D5; } break; case "D6" : global $p0D6; global $p1D6; if ( $currentprocessor == 0 ) { return $p0D6; } else if ( $currentprocessor == 1 ) { return $p1D6; } break; case "D7" : global $p0D7; global $p1D7; if ( $currentprocessor == 0 ) { return $p0D7; } else if ( $currentprocessor == 1 ) { return $p1D7; } break; case "E" : global $p0E; global $p1E; if ( $currentprocessor == 0 ) { return $p0E; } else if ( $currentprocessor == 1 ) { return $p1E; } break; case "FP" : global $p0FP; global $p1FP; if ( $currentprocessor == 0 ) { return $p0FP; } else if ( $currentprocessor == 1 ) { return $p1FP; } break; case "F0" : global $p0F0; global $p1F0; if ( $currentprocessor == 0 ) { return $p0F0; } else if ( $currentprocessor == 1 ) { return $p1F0; } break; case "F1" : global $p0F1; global $p1F1; if ( $currentprocessor == 0 ) { return $p0F1; } else if ( $currentprocessor == 1 ) { return $p1F1; } break; case "F2" : global $p0F2; global $p1F2; if ( $currentprocessor == 0 ) { return $p0F2; } else if ( $currentprocessor == 1 ) { return $p1F2; } break; case "F3" : global $p0F3; global $p1F3; if ( $currentprocessor == 0 ) { return $p0F3; } else if ( $currentprocessor == 1 ) { return $p1F3; } break; case "F4" : global $p0F4; global $p1F4; if ( $currentprocessor == 0 ) { return $p0F4; } else if ( $currentprocessor == 1 ) { return $p1F4; } break; case "F5" : global $p0F5; global $p1F5; if ( $currentprocessor == 0 ) { return $p0F5; } else if ( $currentprocessor == 1 ) { return $p1F5; } break; case "F6" : global $p0F6; global $p1F6; if ( $currentprocessor == 0 ) { return $p0F6; } else if ( $currentprocessor == 1 ) { return $p1F6; } break; case "F7" : global $p0F7; global $p1F7; if ( $currentprocessor == 0 ) { return $p0F7; } else if ( $currentprocessor == 1 ) { return $p1F7; } break; case "F8" : global $p1F8; global $p1F8; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F8 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F8 = $registervalue; } break; case "F9" : global $p1F9; global $p1F9; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F9 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F9 = $registervalue; } break; case "F10" : global $p1F10; global $p1F10; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F10 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F10 = $registervalue; } break; case "F11" : global $p1F11; global $p1F11; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F11 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F11 = $registervalue; } break; case "F12" : global $p1F12; global $p1F12; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F12 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F12 = $registervalue; } break; case "F13" : global $p1F13; global $p1F13; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F13 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F13 = $registervalue; } break; case "F14" : global $p1F14; global $p1F14; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F14 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F14 = $registervalue; } break; case "F15" : global $p1F15; global $p1F15; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F15 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F15 = $registervalue; } break; case "F16" : global $p1F16; global $p1F16; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F16 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F16 = $registervalue; } break; case "F17" : global $p1F17; global $p1F17; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F17 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F17 = $registervalue; } break; case "F18" : global $p1F18; global $p1F18; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F18 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F18 = $registervalue; } break; case "F19" : global $p1F19; global $p1F19; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F19 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F19 = $registervalue; } break; case "F20" : global $p1F20; global $p1F20; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F20 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F20 = $registervalue; } break; case "F21" : global $p1F21; global $p1F21; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F21 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F21 = $registervalue; } break; case "F22" : global $p1F22; global $p1F22; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F22 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F22 = $registervalue; } break; case "F23" : global $p1F23; global $p1F23; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F23 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F23 = $registervalue; } break; case "F24" : global $p1F24; global $p1F24; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F24 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F24 = $registervalue; } break; case "F25" : global $p1F25; global $p1F25; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F25 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F25 = $registervalue; } break; case "F26" : global $p1F26; global $p1F26; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F26 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F26 = $registervalue; } break; case "F27" : global $p1F27; global $p1F27; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F27 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F27 = $registervalue; } break; case "F28" : global $p1F28; global $p1F28; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F28 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F28 = $registervalue; } break; case "F29" : global $p1F29; global $p1F29; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F29 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F29 = $registervalue; } break; case "F30" : global $p1F30; global $p1F30; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F30 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F30 = $registervalue; } break; case "F31" : global $p1F31; global $p1F31; if ( $currentprocessor == 0 ) { /* need to add validation of info for register */ $p1F31 = $registervalue; } else if ( $currentprocessor == 1 ) { /* need to add validation of info for register */ $p1F31 = $registervalue; } break; case "HL" : global $p0HL; global $p1HL; if ( $currentprocessor == 0 ) { return $p0HL; } else if ( $currentprocessor == 1 ) { return $p1HL; } break; case "INDEX" : global $p0indexx; global $p1indexx; if ( $currentprocessor == 0 ) { return $p0indexx; } else if ( $currentprocessor == 1 ) { return $p1indexx; } break; case "INDEX1" : global $p0index1; global $p1index1; if ( $currentprocessor == 0 ) { return $p0index1; } else if ( $currentprocessor == 1 ) { return $p1index1; } break; case "INDEX2" : global $p0index2; global $p1index2; if ( $currentprocessor == 0 ) { return $p0index2; } else if ( $currentprocessor == 1 ) { return $p1index2; } break; case "INDEX3" : global $p0index3; global $p1index3; if ( $currentprocessor == 0 ) { return $p0index3; } else if ( $currentprocessor == 1 ) { return $p1index3; } break; case "INDEX4" : global $p0index4; global $p1index4; if ( $currentprocessor == 0 ) { return $p0index4; } else if ( $currentprocessor == 1 ) { return $p1index4; } break; case "INDEX5" : global $p0index5; global $p1index5; if ( $currentprocessor == 0 ) { return $p0index5; } else if ( $currentprocessor == 1 ) { return $p1index5; } break; case "INDEX6" : global $p0index6; global $p1index6; if ( $currentprocessor == 0 ) { return $p0index6; } else if ( $currentprocessor == 1 ) { return $p1index6; } break; case "JUMP" : global $p0jump; global $p1jump; if ( $currentprocessor == 0 ) { return $p0jump; } else if ( $currentprocessor == 1 ) { return $p1jump; } break; case "LINK" : global $p0link; global $p1link; if ( $currentprocessor == 0 ) { return $p0link; } else if ( $currentprocessor == 1 ) { return $p1link; } break; case "L0" : global $p0L0; global $p1L0; if ( $currentprocessor == 0 ) { return $p0L0; } else if ( $currentprocessor == 1 ) { return $p1L0; } break; case "L1" : global $p0L1; global $p1L1; if ( $currentprocessor == 0 ) { return $p0L1; } else if ( $currentprocessor == 1 ) { return $p1L1; } break; case "L2" : global $p0L2; global $p1L2; if ( $currentprocessor == 0 ) { return $p0L2; } else if ( $currentprocessor == 1 ) { return $p1L2; } break; case "L3" : global $p0L3; global $p1L3; if ( $currentprocessor == 0 ) { return $p0L3; } else if ( $currentprocessor == 1 ) { return $p1L3; } break; case "L4" : global $p0L4; global $p1L4; if ( $currentprocessor == 0 ) { return $p0L4; } else if ( $currentprocessor == 1 ) { return $p1L4; } break; case "L5" : global $p0L5; global $p1L5; if ( $currentprocessor == 0 ) { return $p0L5; } else if ( $currentprocessor == 1 ) { return $p1L5; } break; case "L6" : global $p0L6; global $p1L6; if ( $currentprocessor == 0 ) { return $p0L6; } else if ( $currentprocessor == 1 ) { return $p1L6; } break; case "L7" : global $p0L7; global $p1L7; if ( $currentprocessor == 0 ) { return $p0L7; } else if ( $currentprocessor == 1 ) { return $p1L7; } break; case "L8" : global $p0L8; global $p1L8; if ( $currentprocessor == 0 ) { return $p0L8; } else if ( $currentprocessor == 1 ) { return $p1L8; } break; case "L9" : global $p0L9; global $p1L9; if ( $currentprocessor == 0 ) { return $p0L9; } else if ( $currentprocessor == 1 ) { return $p1L9; } break; case "L10" : global $p0L10; global $p1L10; if ( $currentprocessor == 0 ) { return $p0L10; } else if ( $currentprocessor == 1 ) { return $p1L10; } break; case "L11" : global $p0L11; global $p1L11; if ( $currentprocessor == 0 ) { return $p0L11; } else if ( $currentprocessor == 1 ) { return $p1L11; } break; case "L12" : global $p0L12; global $p1L12; if ( $currentprocessor == 0 ) { return $p0L12; } else if ( $currentprocessor == 1 ) { return $p1L12; } break; case "L13" : global $p0L13; global $p1L13; if ( $currentprocessor == 0 ) { return $p0L13; } else if ( $currentprocessor == 1 ) { return $p1L13; } break; case "L14" : global $p0L14; global $p1L14; if ( $currentprocessor == 0 ) { return $p0L14; } else if ( $currentprocessor == 1 ) { return $p1L14; } break; case "L15" : global $p0L15; global $p1L15; if ( $currentprocessor == 0 ) { return $p0L15; } else if ( $currentprocessor == 1 ) { return $p1L15; } break; case "L16" : global $p0L16; global $p1L16; if ( $currentprocessor == 0 ) { return $p0L16; } else if ( $currentprocessor == 1 ) { return $p1L16; } break; case "L17" : global $p0L17; global $p1L17; if ( $currentprocessor == 0 ) { return $p0L17; } else if ( $currentprocessor == 1 ) { return $p1L17; } break; case "L18" : global $p0L18; global $p1L18; if ( $currentprocessor == 0 ) { return $p0L18; } else if ( $currentprocessor == 1 ) { return $p1L18; } break; case "L19" : global $p0L19; global $p1L19; if ( $currentprocessor == 0 ) { return $p0L19; } else if ( $currentprocessor == 1 ) { return $p1L19; } break; case "L20" : global $p0L20; global $p1L20; if ( $currentprocessor == 0 ) { return $p0L20; } else if ( $currentprocessor == 1 ) { return $p1L20; } break; case "L21" : global $p0L21; global $p1L21; if ( $currentprocessor == 0 ) { return $p0L21; } else if ( $currentprocessor == 1 ) { return $p1L21; } break; case "L22" : global $p0L22; global $p1L22; if ( $currentprocessor == 0 ) { return $p0L22; } else if ( $currentprocessor == 1 ) { return $p1L22; } break; case "L23" : global $p0L23; global $p1L23; if ( $currentprocessor == 0 ) { return $p0L23; } else if ( $currentprocessor == 1 ) { return $p1L23; } break; case "L24" : global $p0L24; global $p1L24; if ( $currentprocessor == 0 ) { return $p0L24; } else if ( $currentprocessor == 1 ) { return $p1L24; } break; case "L25" : global $p0L25; global $p1L25; if ( $currentprocessor == 0 ) { return $p0L25; } else if ( $currentprocessor == 1 ) { return $p1L25; } break; case "L26" : global $p0L26; global $p1L26; if ( $currentprocessor == 0 ) { return $p0L26; } else if ( $currentprocessor == 1 ) { return $p1L26; } break; case "L27" : global $p0L27; global $p1L27; if ( $currentprocessor == 0 ) { return $p0L27; } else if ( $currentprocessor == 1 ) { return $p1L27; } break; case "L28" : global $p0L28; global $p1L28; if ( $currentprocessor == 0 ) { return $p0L28; } else if ( $currentprocessor == 1 ) { return $p1L28; } break; case "L29" : global $p0L29; global $p1L29; if ( $currentprocessor == 0 ) { return $p0L29; } else if ( $currentprocessor == 1 ) { return $p1L29; } break; case "L30" : global $p0L30; global $p1L30; if ( $currentprocessor == 0 ) { return $p0L30; } else if ( $currentprocessor == 1 ) { return $p1L30; } break; case "L31" : global $p0L31; global $p1L31; if ( $currentprocessor == 0 ) { return $p0L31; } else if ( $currentprocessor == 1 ) { return $p1L31; } break; case "PC" : global $p0PC; global $p1PC; if ( $currentprocessor == 0 ) { return $p0PC; } else if ( $currentprocessor == 1 ) { return $p1PC; } break; case "RP" : global $p0srp; global $p1srp; if ( $currentprocessor == 0 ) { return $p0srp; } else if ( $currentprocessor == 1 ) { return $p1srp; } break; case "R0" : global $p0R0; global $p1R0; if ( $currentprocessor == 0 ) { return $p0R0; } else if ( $currentprocessor == 1 ) { return $p1R0; } break; case "R1" : global $p0R1; global $p1R1; if ( $currentprocessor == 0 ) { return $p0R1; } else if ( $currentprocessor == 1 ) { return $p1R1; } break; case "R2" : global $p0R2; global $p1R2; if ( $currentprocessor == 0 ) { return $p0R2; } else if ( $currentprocessor == 1 ) { return $p1R2; } break; case "R3" : global $p0R3; global $p1R3; if ( $currentprocessor == 0 ) { return $p0R3; } else if ( $currentprocessor == 1 ) { return $p1R3; } break; case "R4" : global $p0R4; global $p1R4; if ( $currentprocessor == 0 ) { return $p0R4; } else if ( $currentprocessor == 1 ) { return $p1R4; } break; case "R5" : global $p0R5; global $p1R5; if ( $currentprocessor == 0 ) { return $p0R5; } else if ( $currentprocessor == 1 ) { return $p1R5; } break; case "R6" : global $p0R6; global $p1R6; if ( $currentprocessor == 0 ) { return $p0R6; } else if ( $currentprocessor == 1 ) { return $p1R6; } break; case "R7" : global $p0R7; global $p1R7; if ( $currentprocessor == 0 ) { return $p0R7; } else if ( $currentprocessor == 1 ) { return $p1R7; } break; case "R8" : global $p0R8; global $p1R8; if ( $currentprocessor == 0 ) { return $p0R8; } else if ( $currentprocessor == 1 ) { return $p1R8; } break; case "R9" : global $p0R9; global $p1R9; if ( $currentprocessor == 0 ) { return $p0R9; } else if ( $currentprocessor == 1 ) { return $p1R9; } break; case "R10" : global $p0R10; global $p1R10; if ( $currentprocessor == 0 ) { return $p0R10; } else if ( $currentprocessor == 1 ) { return $p1R10; } break; case "R11" : global $p0R11; global $p1R11; if ( $currentprocessor == 0 ) { return $p0R11; } else if ( $currentprocessor == 1 ) { return $p1R11; } break; case "R12" : global $p0R12; global $p1R12; if ( $currentprocessor == 0 ) { return $p0R12; } else if ( $currentprocessor == 1 ) { return $p1R12; } break; case "R13" : global $p0R13; global $p1R13; if ( $currentprocessor == 0 ) { return $p0R13; } else if ( $currentprocessor == 1 ) { return $p1R13; } break; case "R14" : global $p0R14; global $p1R14; if ( $currentprocessor == 0 ) { return $p0R14; } else if ( $currentprocessor == 1 ) { return $p1R14; } break; case "R15" : global $p0R15; global $p1R15; if ( $currentprocessor == 0 ) { return $p0R15; } else if ( $currentprocessor == 1 ) { return $p1R15; } break; case "R16" : global $p0R16; global $p1R16; if ( $currentprocessor == 0 ) { return $p0R16; } else if ( $currentprocessor == 1 ) { return $p1R16; } break; case "R17" : global $p0R17; global $p1R17; if ( $currentprocessor == 0 ) { return $p0R17; } else if ( $currentprocessor == 1 ) { return $p1R17; } break; case "R18" : global $p0R18; global $p1R18; if ( $currentprocessor == 0 ) { return $p0R18; } else if ( $currentprocessor == 1 ) { return $p1R18; } break; case "R19" : global $p0R19; global $p1R19; if ( $currentprocessor == 0 ) { return $p0R19; } else if ( $currentprocessor == 1 ) { return $p1R19; } break; case "R20" : global $p0R20; global $p1R20; if ( $currentprocessor == 0 ) { return $p0R20; } else if ( $currentprocessor == 1 ) { return $p1R20; } break; case "R21" : global $p0R21; global $p1R21; if ( $currentprocessor == 0 ) { return $p0R21; } else if ( $currentprocessor == 1 ) { return $p1R21; } break; case "R22" : global $p0R22; global $p1R22; if ( $currentprocessor == 0 ) { return $p0R22; } else if ( $currentprocessor == 1 ) { return $p1R22; } break; case "R23" : global $p0R23; global $p1R23; if ( $currentprocessor == 0 ) { return $p0R23; } else if ( $currentprocessor == 1 ) { return $p1R23; } break; case "R24" : global $p0R24; global $p1R24; if ( $currentprocessor == 0 ) { return $p0R24; } else if ( $currentprocessor == 1 ) { return $p1R24; } break; case "R25" : global $p0R25; global $p1R25; if ( $currentprocessor == 0 ) { return $p0R25; } else if ( $currentprocessor == 1 ) { return $p1R25; } break; case "R26" : global $p0R26; global $p1R26; if ( $currentprocessor == 0 ) { return $p0R26; } else if ( $currentprocessor == 1 ) { return $p1R26; } break; case "R27" : global $p0R27; global $p1R27; if ( $currentprocessor == 0 ) { return $p0R27; } else if ( $currentprocessor == 1 ) { return $p1R27; } break; case "R28" : global $p0R28; global $p1R28; if ( $currentprocessor == 0 ) { return $p0R28; } else if ( $currentprocessor == 1 ) { return $p1R28; } break; case "R29" : global $p0R29; global $p1R29; if ( $currentprocessor == 0 ) { return $p0R29; } else if ( $currentprocessor == 1 ) { return $p1R29; } break; case "R30" : global $p0R30; global $p1R30; if ( $currentprocessor == 0 ) { return $p0R30; } else if ( $currentprocessor == 1 ) { return $p1R30; } break; case "R31" : global $p0R31; global $p1R31; if ( $currentprocessor == 0 ) { return $p0R31; } else if ( $currentprocessor == 1 ) { return $p1R31; } break; case "SP" : global $p0SP; global $p1SP; if ( $currentprocessor == 0 ) { return $p0SP; } else if ( $currentprocessor == 1 ) { return $p1SP; } break; case "SRP" : global $p0srp; global $p1srp; if ( $currentprocessor == 0 ) { return $p0srp; } else if ( $currentprocessor == 1 ) { return $p1srp; } break; case "X" : global $p0indexx; global $p1indexx; if ( $currentprocessor == 0 ) { return $p0indexx; } else if ( $currentprocessor == 1 ) { return $p1indexx; } break; case "Y" : global $p0indexy; global $p1indexy; if ( $currentprocessor == 0 ) { return $p0indexy; } else if ( $currentprocessor == 1 ) { return $p1indexy; } break; case "ZERO" : /* zero register only has zero as contents */ return "00000000"; break; default : $errortype = "BAD REGISTER SPECIFICATION: ".$registername; } } /******************************/ /* FUNCTION: ParseInstruction() */ /* output: TRUE = found */ /* output: FALSE = not found */ /* output: side effects */ /******************************/ function ParseInstruction() { global $tokenstring; switch ($tokenstring[COMMANDPOS]) { case "CMA" : /* 8080/8085/Z80 instruction */ /* complement low order byte of ACC (A register) */ if ( $currentprocessor == 0 ) { global $p0acc; $tempbyte = ExtractByte($p0acc, 0); /* low byte of register A */ $firstcharacter = substr($tempbyte,0,1); $secondcharacter = substr($tempbyte,1,1); $tempbitstring = HexDigitToBits($firstcharacter).HexDigitToBits($secondcharacter); $tempbitstring = OpNot($tempbitstring); $firststring = substr($tempbitstring,0,4); $secondstring = substr($tempbitstring,4,4); $firstcharacter = BitstoHexDigit($firststring); $secondcharacter = BitstoHexDigit($secondstring); $newvalue = $firstcharacter.$secondcharacter; $p0acc = InsertByte($p0acc,$newvalue,0); } elseif ( $currentprocessor == 1 ) { global $p1acc; $tempbyte = ExtractByte($p1acc, 0); /* low byte of register A */ $firstcharacter = substr($tempbyte,0,1); $secondcharacter = substr($tempbyte,1,1); $tempbitstring = HexDigitToBits($firstcharacter).HexDigitToBits($secondcharacter); $tempbitstring = OpNot($tempbitstring); $firststring = substr($tempbitstring,0,4); $secondstring = substr($tempbitstring,4,4); $firstcharacter = BitstoHexDigit($firststring); $secondcharacter = BitstoHexDigit($secondstring); $newvalue = $firstcharacter.$secondcharacter; $p1acc = InsertByte($p1acc,$newvalue,0); } $validentry = TRUE; return TRUE; break; case "MOV" : /* move data from one location to another */ /* add validation */ /* remove trailing comma if it exists */ $firstcomma = strpos($tokenstring[FIRSTPARAMPOS], ','); /* find first comma, if any */ if ( $firstcomma >= 1 ) { $tokenstring[FIRSTPARAMPOS] = substr($tokenstring[FIRSTPARAMPOS],0,$firstcomma); /* chop trailing comma */ } $tempvalue = ValueFromRegister($tokenstring[SECONDPARAMPOS]); LoadRegister($tokenstring[FIRSTPARAMPOS], $tempvalue); $validentry = TRUE; return TRUE; break; case "MOVE" : /* move data from one location to another */ /* add validation */ /* remove trailing comma if it exists */ $firstcomma = strpos($tokenstring[FIRSTPARAMPOS], ','); /* find first comma, if any */ if ( $firstcomma >= 1 ) { $tokenstring[FIRSTPARAMPOS] = substr($tokenstring[FIRSTPARAMPOS],0,$firstcomma); /* chop trailing comma */ } $tempvalue = ValueFromRegister($tokenstring[SECONDPARAMPOS]); LoadRegister($tokenstring[FIRSTPARAMPOS], $tempvalue); $validentry = TRUE; return TRUE; break; case "MOVAA" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ /* no change, so no reason to move to self */ $validentry = TRUE; return TRUE; break; case "MOVAB" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0acc; global $p0b; $p0acc = InsertByte($p0acc, ExtractByte($p0b, 0), 0); /* low byte of register B moved to A */ } elseif ( $currentprocessor == 1 ) { global $p1acc; global $p1b; $p1acc = substr($p1b,-2,2); /* low byte of register B moved to A */ } $validentry = TRUE; return TRUE; break; case "MOVAC" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0acc; global $p0c; $p0acc = substr($p0c,-2,2); /* low byte of register C moved to A */ } elseif ( $currentprocessor == 1 ) { global $p1acc; global $p1c; $p1acc = substr($p1c,-2,2); /* low byte of register C moved to A */ } $validentry = TRUE; return TRUE; break; case "MOVAD" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0acc; global $p0d; $p0acc = substr($p0d,-2,2); /* low byte of register D moved to A */ } elseif ( $currentprocessor == 1 ) { global $p1acc; global $p1d; $p1acc = substr($p1d,-2,2); /* low byte of register D moved to a */ } $validentry = TRUE; return TRUE; break; case "MOVAE" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0acc; global $p0e; $p0acc = substr($p0e,-2,2); /* low byte of register E moved to A */ } elseif ( $currentprocessor == 1 ) { global $p1acc; global $p1e; $p1acc = substr($p1e,-2,2); /* low byte of register E moved to A */ } $validentry = TRUE; return TRUE; break; case "MOVAH" : /* 8080/8085/Z80 instruction */ /* register to register move of high order byte */ if ( $currentprocessor == 0 ) { global $p0acc; global $p0HL; $p0acc = InsertByte($p0acc, ExtractByte($p0HL, 1), 0); /* low byte of register B moved to A */ } elseif ( $currentprocessor == 1 ) { global $p1acc; global $p1HL; $p1acc = substr($p1HL,-4,2); /* high byte of register HL moved to A */ } $validentry = TRUE; return TRUE; break; case "MOVAL" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0acc; global $p0HL; $p0acc = substr($p0HL,-2,2); /* low byte of register HL moved to A */ } elseif ( $currentprocessor == 1 ) { global $p1acc; global $p1HL; $p1acc = substr($p1HL,-2,2); /* low byte of register HL moved to A */ } $validentry = TRUE; return TRUE; break; case "MOVBA" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0b; global $p0acc; $p0b = substr($p0acc,-2,2); /* low byte of register A moved to B */ } elseif ( $currentprocessor == 1 ) { global $p1b; global $p1acc; $p1b = substr($p1acc,-2,2); /* low byte of register A moved to B */ } $validentry = TRUE; return TRUE; break; case "MOVBB" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ /* no change, so no reason to move to self */ $validentry = TRUE; return TRUE; break; case "MOVBC" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0b; global $p0c; $p0b = substr($p0c,-2,2); /* low byte of register C moved to B */ } elseif ( $currentprocessor == 1 ) { global $p1b; global $p1c; $p1b = substr($p1c,-2,2); /* low byte of register C moved to B */ } $validentry = TRUE; return TRUE; break; case "MOVBD" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0b; global $p0d; $p0b = substr($p0d,-2,2); /* low byte of register D moved to B */ } elseif ( $currentprocessor == 1 ) { global $p1b; global $p1d; $p1b = substr($p1d,-2,2); /* low byte of register D moved to B */ } $validentry = TRUE; return TRUE; break; case "MOVBE" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0b; global $p0e; $p0b = substr($p0e,-2,2); /* low byte of register E moved to B */ } elseif ( $currentprocessor == 1 ) { global $p1b; global $p1e; $p1b = substr($p1e,-2,2); /* low byte of register E moved to B */ } $validentry = TRUE; return TRUE; break; case "MOVBH" : /* 8080/8085/Z80 instruction */ /* register to register move of high order byte */ if ( $currentprocessor == 0 ) { global $p0b; global $p0HL; $p0b = substr($p0HL,-4,2); /* high byte of register HL moved to B */ } elseif ( $currentprocessor == 1 ) { global $p1b; global $p1HL; $p1b = substr($p1HL,-4,2); /* high byte of register HL moved to B */ } $validentry = TRUE; return TRUE; break; case "MOVBL" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0b; global $p0HL; $p0b = substr($p0HL,-2,2); /* low byte of register HL moved to B */ } elseif ( $currentprocessor == 1 ) { global $p1b; global $p1HL; $p1b = substr($p1HL,-2,2); /* low byte of register HL moved to B */ } $validentry = TRUE; return TRUE; break; case "MOVCA" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0c; global $p0acc; $p0c = substr($p0acc,-2,2); /* low byte of register A moved to C */ } elseif ( $currentprocessor == 1 ) { global $p1c; global $p1acc; $p1c = substr($p1acc,-2,2); /* low byte of register A moved to C */ } $validentry = TRUE; return TRUE; break; case "MOVCB" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0c; global $p0b; $p0c = substr($p0b,-2,2); /* low byte of register B moved to C */ } elseif ( $currentprocessor == 1 ) { global $p1c; global $p1b; $p1c = substr($p1b,-2,2); /* low byte of register B moved to C */ } $validentry = TRUE; return TRUE; break; case "MOVCC" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ /* no change, so no reason to move to self */ $validentry = TRUE; return TRUE; break; case "MOVCD" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0c; global $p0d; $p0c = substr($p0d,-2,2); /* low byte of register D moved to C */ } elseif ( $currentprocessor == 1 ) { global $p1c; global $p1d; $p1c = substr($p1d,-2,2); /* low byte of register D moved to C */ } $validentry = TRUE; return TRUE; break; case "MOVCE" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0c; global $p0e; $p0c = substr($p0e,-2,2); /* low byte of register E moved to C */ } elseif ( $currentprocessor == 1 ) { global $p1c; global $p1e; $p1c = substr($p1e,-2,2); /* low byte of register E moved to C */ } $validentry = TRUE; return TRUE; break; case "MOVCH" : /* 8080/8085/Z80 instruction */ /* register to register move of high order byte */ if ( $currentprocessor == 0 ) { global $p0c; global $p0HL; $p0c = substr($p0HL,-4,2); /* high byte of register HL moved to C */ } elseif ( $currentprocessor == 1 ) { global $p1c; global $p1HL; $p1c = substr($p1HL,-4,2); /* high byte of register HL moved to C */ } $validentry = TRUE; return TRUE; break; case "MOVCL" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0c; global $p0HL; $p0c = substr($p0HL,-2,2); /* low byte of register HL moved to C */ } elseif ( $currentprocessor == 1 ) { global $p1c; global $p1HL; $p1c = substr($p1HL,-2,2); /* low byte of register HL moved to C */ } $validentry = TRUE; return TRUE; break; case "MOVDA" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0d; global $p0acc; $p0d = substr($p0acc,-2,2); /* low byte of register A moved to D */ } elseif ( $currentprocessor == 1 ) { global $p1d; global $p1acc; $p1d = substr($p1acc,-2,2); /* low byte of register A moved to D */ } $validentry = TRUE; return TRUE; break; case "MOVDB" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0d; global $p0b; $p0d = substr($p0b,-2,2); /* low byte of register B moved to D */ } elseif ( $currentprocessor == 1 ) { global $p1d; global $p1b; $p1d = substr($p1b,-2,2); /* low byte of register B moved to D */ } $validentry = TRUE; return TRUE; break; case "MOVDC" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0d; global $p0c; $p0d = substr($p0c,-2,2); /* low byte of register C moved to D */ } elseif ( $currentprocessor == 1 ) { global $p1d; global $p1c; $p1d = substr($p1c,-2,2); /* low byte of register C moved to D */ } $validentry = TRUE; return TRUE; break; case "MOVDD" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ /* no change, so no reason to move to self */ $validentry = TRUE; return TRUE; break; case "MOVDE" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0d; global $p0e; $p0d = substr($p0e,-2,2); /* low byte of register E moved to D */ } elseif ( $currentprocessor == 1 ) { global $p1d; global $p1e; $p1d = substr($p1e,-2,2); /* low byte of register E moved to D */ } $validentry = TRUE; return TRUE; break; case "MOVDH" : /* 8080/8085/Z80 instruction */ /* register to register move of high order byte */ if ( $currentprocessor == 0 ) { global $p0d; global $p0HL; $p0d = substr($p0HL,-4,2); /* high byte of register HL moved to D */ } elseif ( $currentprocessor == 1 ) { global $p1d; global $p1HL; $p1d = substr($p1HL,-4,2); /* high byte of register HL moved to D */ } $validentry = TRUE; return TRUE; break; case "MOVDL" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0d; global $p0HL; $p0d = substr($p0HL,-2,2); /* low byte of register HL moved to D */ } elseif ( $currentprocessor == 1 ) { global $p1d; global $p1HL; $p1d = substr($p1HL,-2,2); /* low byte of register HL moved to D */ } $validentry = TRUE; return TRUE; break; case "MOVEA" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0e; global $p0acc; $p0e = substr($p0acc,-2,2); /* low byte of register A moved to E */ } elseif ( $currentprocessor == 1 ) { global $p1e; global $p1acc; $p1e = substr($p1acc,-2,2); /* low byte of register A moved to E */ } $validentry = TRUE; return TRUE; break; case "MOVEB" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0e; global $p0b; $p0e = substr($p0b,-2,2); /* low byte of register B moved to E */ } elseif ( $currentprocessor == 1 ) { global $p1e; global $p1b; $p1e = substr($p1b,-2,2); /* low byte of register B moved to E */ } $validentry = TRUE; return TRUE; break; case "MOVEC" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0e; global $p0c; $p0e = substr($p0c,-2,2); /* low byte of register C moved to E */ } elseif ( $currentprocessor == 1 ) { global $p1e; global $p1c; $p1e = substr($p1c,-2,2); /* low byte of register C moved to E */ } $validentry = TRUE; return TRUE; break; case "MOVED" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0e; global $p0d; $p0e = substr($p0d,-2,2); /* low byte of register D moved to E */ } elseif ( $currentprocessor == 1 ) { global $p1e; global $p1d; $p1e = substr($p1d,-2,2); /* low byte of register D moved to E */ } $validentry = TRUE; return TRUE; break; case "MOVEE" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ /* no change, so no reason to move to self */ $validentry = TRUE; return TRUE; break; case "MOVEH" : /* 8080/8085/Z80 instruction */ /* register to register move of high order byte */ if ( $currentprocessor == 0 ) { global $p0e; global $p0HL; $p0e = substr($p0HL,-4,2); /* high byte of register HL moved to E */ } elseif ( $currentprocessor == 1 ) { global $p1e; global $p1HL; $p1e = substr($p1HL,-4,2); /* high byte of register HL moved to E */ } $validentry = TRUE; return TRUE; break; case "MOVEL" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0e; global $p0HL; $p0e = substr($p0HL,-2,2); /* low byte of register HL moved to E */ } elseif ( $currentprocessor == 1 ) { global $p1e; global $p1HL; $p1e = substr($p1HL,-2,2); /* low byte of register HL moved to E */ } $validentry = TRUE; return TRUE; break; case "MOVLA" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0HL; global $p0acc; $temp1 = substr($p0acc,-2,2); /* low byte of register A */ $temp2 = substr($p0HL,-4,2); /* high byte of register HL */ $p0HL = $temp2.$temp1; /* low byte of register A moved to L */ } elseif ( $currentprocessor == 1 ) { global $p1HL; global $p1acc; $temp1 = substr($p1acc,-2,2); /* low byte of register A */ $temp2 = substr($p1HL,-4,2); /* high byte of register HL */ $p1HL = $temp2.$temp1; /* low byte of register A moved to L */ } $validentry = TRUE; return TRUE; break; case "MOVLB" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0HL; global $p0b; $temp1 = substr($p0b,-2,2); /* low byte of register B */ $temp2 = substr($p0HL,-4,2); /* high byte of register HL */ $p0HL = $temp2.$temp1; /* low byte of register B moved to L */ } elseif ( $currentprocessor == 1 ) { global $p1HL; global $p1b; $temp1 = substr($p1b,-2,2); /* low byte of register B */ $temp2 = substr($p1HL,-4,2); /* high byte of register HL */ $p1HL = $temp2.$temp1; /* low byte of register B moved to L */ } $validentry = TRUE; return TRUE; break; case "MOVLC" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0HL; global $p0c; $temp1 = substr($p0c,-2,2); /* low byte of register C */ $temp2 = substr($p0HL,-4,2); /* high byte of register HL */ $p0HL = $temp2.$temp1; /* low byte of register C moved to L */ } elseif ( $currentprocessor == 1 ) { global $p1HL; global $p1c; $temp1 = substr($p1c,-2,2); /* low byte of register C */ $temp2 = substr($p1HL,-4,2); /* high byte of register HL */ $p1HL = $temp2.$temp1; /* low byte of register C moved to L */ } $validentry = TRUE; return TRUE; break; case "MOVLD" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0HL; global $p0d; $temp1 = substr($p0d,-2,2); /* low byte of register D */ $temp2 = substr($p0HL,-4,2); /* high byte of register HL */ $p0HL = $temp2.$temp1; /* low byte of register D moved to L */ } elseif ( $currentprocessor == 1 ) { global $p1HL; global $p1d; $temp1 = substr($p1d,-2,2); /* low byte of register D */ $temp2 = substr($p1HL,-4,2); /* high byte of register HL */ $p1HL = $temp2.$temp1; /* low byte of register D moved to L */ } $validentry = TRUE; return TRUE; break; case "MOVLE" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ if ( $currentprocessor == 0 ) { global $p0HL; global $p0e; $temp1 = substr($p0e,-2,2); /* low byte of register E */ $temp2 = substr($p0HL,-4,2); /* high byte of register HL */ $p0HL = $temp2.$temp1; /* low byte of register E moved to L */ } elseif ( $currentprocessor == 1 ) { global $p1HL; global $p1e; $temp1 = substr($p1e,-2,2); /* low byte of register E */ $temp2 = substr($p1HL,-4,2); /* high byte of register HL */ $p1HL = $temp2.$temp1; /* low byte of register E moved to L */ } $validentry = TRUE; return TRUE; break; case "MOVLH" : /* 8080/8085/Z80 instruction */ /* register to register move of high order byte */ if ( $currentprocessor == 0 ) { global $p0HL; $temp2 = substr($p0HL,-4,2); /* high byte of register HL */ $p0HL = $temp2.$temp2; /* high byte of register HL moved to L */ } elseif ( $currentprocessor == 1 ) { global $p1HL; $temp2 = substr($p1HL,-4,2); /* high byte of register HL */ $p1HL = $temp2.$temp2; /* high byte of register HL moved to L */ } $validentry = TRUE; return TRUE; break; case "MOVLL" : /* 8080/8085/Z80 instruction */ /* register to register move of low order byte */ /* no change, so no reason to move to self */ $validentry = TRUE; return TRUE; break; case "MOVMA" : /* 8080/8085/Z80 instruction */ /* save a byte into the designated memory location */ /* use associative array for storing memory, which will be sparse */ global $memory; if ( $currentprocessor == 0 ) { global $p0HL; global $p0acc; $keypart = (string)$p0HL; $valuepart = substr($p0acc,-2,2); /* store copy of low byte of A register */ $memory[(string)$keypart] = (string)$valuepart; } elseif ( $currentprocessor == 1 ) { global $p1HL; global $p1acc; $memory[(string)$p1HL] = substr($p1acc,-2,2); /* store copy of low byte of A register */ } $validentry = TRUE; return TRUE; break; case "MOVMB" : /* 8080/8085/Z80 instruction */ /* save a byte into the designated memory location */ /* use associative array for storing memory, which will be sparse */ global $memory; if ( $currentprocessor == 0 ) { global $p0HL; global $p0b; $keypart = (string)$p0HL; $valuepart = substr($p0b,-2,2); /* store copy of low byte of B register */ $memory[(string)$keypart] = (string)$valuepart; } elseif ( $currentprocessor == 1 ) { global $p1HL; global $p1b; $memory[(string)$p1HL] = substr($p1b,-2,2); /* store copy of low byte of B register */ } $validentry = TRUE; return TRUE; break; case "MOVMC" : /* 8080/8085/Z80 instruction */ /* save a byte into the designated memory location */ /* use associative array for storing memory, which will be sparse */ global $memory; if ( $currentprocessor == 0 ) { global $p0HL; global $p0c; $keypart = (string)$p0HL; $valuepart = substr($p0c,-2,2); /* store copy of low byte of C register */ $memory[(string)$keypart] = (string)$valuepart; } elseif ( $currentprocessor == 1 ) { global $p1HL; global $p1c; $memory[(string)$p1HL] = substr($p1c,-2,2); /* store copy of low byte of C register */ } $validentry = TRUE; return TRUE; break; case "MOVMD" : /* 8080/8085/Z80 instruction */ /* save a byte into the designated memory location */ /* use associative array for storing memory, which will be sparse */ global $memory; if ( $currentprocessor == 0 ) { global $p0HL; global $p0d; $keypart = (string)$p0HL; $valuepart = substr($p0d,-2,2); /* store copy of low byte of D register */ $memory[(string)$keypart] = (string)$valuepart; } elseif ( $currentprocessor == 1 ) { global $p1HL; global $p1d; $memory[(string)$p1HL] = substr($p1d,-2,2); /* store copy of low byte of D register */ } $validentry = TRUE; return TRUE; break; case "MOVME" : /* 8080/8085/Z80 instruction */ /* save a byte into the designated memory location */ /* use associative array for storing memory, which will be sparse */ global $memory; if ( $currentprocessor == 0 ) { global $p0HL; global $p0e; $keypart = (string)$p0HL; $valuepart = substr($p0e,-2,2); /* store copy of low byte of E register */ $memory[(string)$keypart] = (string)$valuepart; } elseif ( $currentprocessor == 1 ) { global $p1HL; global $p1e; $memory[(string)$p1HL] = substr($p1e,-2,2); /* store copy of low byte of E register */ } $validentry = TRUE; return TRUE; break; case "MOVMH" : /* 8080/8085/Z80 instruction */ /* save a byte into the designated memory location */ /* use associative array for storing memory, which will be sparse */ global $memory; if ( $currentprocessor == 0 ) { global $p0HL; $keypart = (string)$p0HL; $valuepart = substr($p0HL,-4,2); /* store copy of high byte of HL register */ $memory[(string)$keypart] = (string)$valuepart; } elseif ( $currentprocessor == 1 ) { global $p1HL; $memory[(string)$p1HL] = substr($p1HL,-4,2); /* store copy of low byte of HL register */ } $validentry = TRUE; return TRUE; break; case "MOVML" : /* 8080/8085/Z80 instruction */ /* save a byte into the designated memory location */ /* use associative array for storing memory, which will be sparse */ global $memory; if ( $currentprocessor == 0 ) { global $p0HL; $keypart = (string)$p0HL; $valuepart = substr($p0HL,-2,2); /* store copy of low byte of Hl register */ $memory[(string)$keypart] = (string)$valuepart; } elseif ( $currentprocessor == 1 ) { global $p1HL; $memory[(string)$p1HL] = substr($p1HL,-2,2); /* store copy of low byte of HL register */ } $validentry = TRUE; return TRUE; break; default : $errortype = "BAD COMMAND OR INSTRUCTION"; return FALSE; } /* end case */ } /* end function */ /* the promosed "CONTINUATION OF WORKING CODE" */ /******************************/ /* PARSE COMMAND */ /* I am using a table approach because it is */ /* faster to code */ /******************************/ $initialstring = $entryline; /* save a copy of the original input line */ /******************************/ /* FIND TOKENS */ /******************************/ $workstring = trim($entryline); /* working copy of trimmed original input line */ /* this eliminates white space at beginning and end of line */ $validentry = FALSE; /* set to false in case we have bad results */ /* test for empty line or comment only line */ if ( $workstring == '' ) /* test for empty line */ { $validentry = TRUE; } else { $firstcharacter = substr($workstring,0,1); /* get first character */ if ( $firstcharacter == ';' ) /* test for comment */ { $validentry = TRUE; } } /* break work string into tokens */ $numtokens = 0; /* initialize to none found so far */ $stilltokenizing = TRUE; $tokenstring[LABELPOS] = "*"; /* set zero element to empty string */ /* asterisk is used to indicate there is no label, but keep the string passed to web browser of consistent contents */ while ( $stilltokenizing == TRUE ) { $workstring = trim($workstring); /* eliminate white space at beginning and end of line */ /* test for empty line - no more tokens */ if ( $workstring == '' ) /* test for empty line */ { $stilltokenizing = FALSE; break; } /* test for comment (to end of line) - no more tokens */ $firstcharacter = substr($workstring,0,1); /* get first character */ if ( $firstcharacter == ';' ) /* test for comment */ { $stilltokenizing = FALSE; break; } /* FIND END OF TOKEN */ /* first of semicolon, space, comma, or end of line */ $worklength = strlen($workstring); /* find current length */ $firstcomma = strpos($workstring, ','); /* find first comma, if any */ $firstspace = strpos($workstring, ' '); /* find first space, if any */ $firstsemicolon = strpos($workstring, ';'); /* find first semicolon, if any */ $tempresult = $worklength - 1; if ( ( ! ( $firstcomma === FALSE ) AND $firstcomma < $tempresult) ) { $tempresult = $firstcomma; } if ( ! ( $firstspace === FALSE ) AND ( $firstspace < $tempresult ) ) { $tempresult = $firstspace; } if ( ! ( $firstsemicolon === FALSE ) AND ( $firstsemicolon < $tempresult ) ) { $tempresult = $firstsemicolon - 1; /* leave semicolon to start next token, so we will correctly recognize a comment */ } /* GET TOKEN */ $numtokens = $numtokens + 1; $tempresult = $tempresult + 1; $temporaryvariable = substr($workstring,0,$tempresult); /* get token including marker */ $tokenstring[$numtokens] = trim($temporaryvariable); /* eliminate white space at beginning and end of line */ /* REMOVE TOKEN AND SEPARATOR FROM WORK STRING */ /* $worklength = strlen($workstring); /* find current length */ $restofstring = substr($workstring,$tempresult,$worklength); $workstring = trim($restofstring); /* test for end of string */ if ( $workstring == '' ) { $stilltokenizing == FALSE; break; /* use break to end loop */ } /* maximum of ten tokens */ if ( $numtokens == 10 ) { $stilltokenizing == FALSE; break; /* use break to end loop */ } } /* if first token is a label, move label token to zero position */ /* otherwise, zero element is already empty string */ /* and other tokens are already in position */ /* with the token count position now clear */ $lastcharacterposition = strlen($tokenstring[1]); if ( substr($tokenstring[1],-1) == ":" ) { $tokenstring[LABELPOS] = $tokenstring[TOKENCOUNTPOS]; $numtokens = $numtokens - 1; } /* otherwise there is no label */ /* now move all elements other than optional label to the right by one element */ /* to leave space for the token count to be inserted into position 1 of array */ else { for ($loopvariable = $numtokens; $loopvariable > 0; $loopvariable -= 1) { $tokenstring[$loopvariable+1] = $tokenstring[$loopvariable]; } } /* and store token count in array element one */ $tokenstring[TOKENCOUNTPOS] = $numtokens; /* now have array structure of: */ /* zero LABELPOS is optional label */ /* one TOKENCOUNTPOS is count of number of tokens other than optional label */ /* two COMMANDPOS is the instruction or command */ /* remaining are optional additional tokens */ /* make shadow copy before turning everything into upper case */ for ($loopvariable = 0; $loopvariable <= $numtokens + 1; $loopvariable += 1) { $shadowtokens[$loopvariable] = $tokenstring[$loopvariable]; } /* turn all tokens (other than label) into upper case */ /* for ease of interpretation */ for ($loopvariable = 1; $loopvariable <= $numtokens + 1; $loopvariable += 1) { $tokenstring[$loopvariable] = strtoupper($tokenstring[$loopvariable]); } /******************************/ /* INTERPRET TOKEN */ /******************************/ switch ($tokenstring[COMMANDPOS]) { case "ACTION" : $mode = "!"; $validentry = TRUE; break; case "ASSEMBLE" : $mode = ">"; $validentry = TRUE; break; case "CHANGE" : switch ($tokenstring[FIRSTPARAMPOS]) { /* nested case */ case "A" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "ACC" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "AP" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "A0" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "A1" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "A2" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "A3" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "A4" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "A5" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "A6" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "A7" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "B" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "C" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "COUNT" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "D" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "D0" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "D1" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "D2" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "D3" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "D4" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "D5" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "D6" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "D7" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "E" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "FP" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F0" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F1" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F2" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F3" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F4" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F5" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F6" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F7" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F8" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F9" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F10" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F11" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F12" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F13" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F14" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F15" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F16" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F17" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F18" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F19" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F20" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F21" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F22" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F23" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F24" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F25" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F26" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F27" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F28" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F29" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F30" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "F31" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "HL" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "INDEX" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "INDEX1" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "INDEX2" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "INDEX3" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "INDEX4" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "INDEX5" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "INDEX6" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "JUMP" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "LINK" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L0" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L1" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L2" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L3" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L4" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L5" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L6" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L7" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L8" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L9" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L10" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L11" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L12" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L13" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L14" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L15" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L16" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L17" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L18" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L19" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L20" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L21" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L22" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L23" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L24" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L25" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L26" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L27" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L28" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L29" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L30" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "L31" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "P0" : $currentprocessor = "0"; $validentry = TRUE; break; case "P1" : $currentprocessor = "1"; $validentry = TRUE; break; case "PC" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "RP" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R0" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R1" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R2" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R3" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R4" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R5" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R6" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R7" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R8" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R9" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R10" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R11" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R12" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R13" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R14" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R15" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R16" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R17" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R18" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R19" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R20" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R21" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R22" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R23" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R24" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R25" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R26" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R27" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R28" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R29" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R30" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "R31" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "SP" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "SRP" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "X" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; case "Y" : LoadRegister($tokenstring[FIRSTPARAMPOS], $tokenstring[SECONDPARAMPOS]); $validentry = TRUE; break; /* can't change the zero register */ default : $errortype = "BAD PARAMETER TO CHANGE COMMAND: ".$tokenstring[FIRSTPARAMPOS]; } /* end change */ break; case "COMPILE" : $mode = ">"; $validentry = TRUE; break; case "DISPLAY" : if ( $tokenstring[FIRSTPARAMPOS] == "MEMORY" ) { $displaymemoryflag = TRUE; } elseif ( $tokenstring[FIRSTPARAMPOS] == "CODE" ) { $displaycodememoryflag = TRUE; } $validentry = TRUE; break; case "IMMEDIATE" : $mode = "!"; $validentry = TRUE; break; case "SUBMIT" : /* insert school-specific code for submitting assignments */ $schoolspecific = "Submit requires a school-specific implementation, please speak to your professor."; $validentry = TRUE; break; default : if ( $mode == ">" ) { /* store the instruction (compile mode */ /* in the future add code to verify the instruction */ /* for now will just store anything and let it blow up when run */ /* get current program counter (index into $codearray ) */ if ( $currentprocessor == "0" ) { $placeholder = (string)"0".$p0PC; $placeholder = hexdec($placeholder); $tempPC = $placeholder + 1; $tempPC = dechex($tempPC); $p0PC = $tempPC; } elseif ( $currentprocessor == "1" ) { $placeholder = (string)"0".$p1PC; $placeholder = hexdec($placeholder); $p1PC += 1; $p1PC = dechex($p1PC); } /* change code array size if PC greater than previous code size */ if ( $tempPC > $p0codesize ) { $p0codesize = $tempPC; } /* trim leading zeros from $plaaceholder */ /* place current tokens into $codearray[PC][token positions] */ for ($loopvariable = 0; $loopvariable <= $numtokens + 1; $loopvariable += 1) { $codearray[$placeholder][$loopvariable] = $tokenstring[$loopvariable]; } /* remember to add validation */ $resultcode = TRUE; } elseif ( $mode == "!" ) { /* run the instruction (immediate mode */ $resultcode = ParseInstruction(); } if ( $resultcode ) { $validentry = TRUE; } else { $errortype = "BAD COMMAND OR INSTRUCTION"; } } /******************************/ /* IMPLEMENT INSTRUCTION OR COMMAND */ /******************************/ /* note that this area is going to disappear - change of plans */ /* echo "
after switch/case: substring is ".substr($p0acc,-2,2)."
p0HL is ".$p0HL."
memory is ".$memory; /* debugging line no longer needed */ /******************************/ /* REPORT RESULTS */ /******************************/ ?>
processor 0"; echo ""; echo "

type: ".$p0type; if ( $p0type == "0" ) { echo " (GENERIC)"; } elseif ( $p0type == "A" ) { echo " (Intel 8080)"; } echo ""; if ( ereg('[0A]',$p0type,$matches) ) { echo "

ACCumulator: ".$p0acc; } echo ""; echo "
B register: ".$p0b; echo ""; echo "
C register: ".$p0c; echo ""; echo "
D register: ".$p0d; echo ""; echo "
E register: ".$p0e; echo "
HL: ".$p0HL; echo ""; echo "
index X: ".$p0indexx; echo ""; echo "
index Y: ".$p0indexy; echo ""; echo "
index 1: ".$p0index1; echo ""; echo "
index 2: ".$p0index2; echo ""; echo "
index 3: ".$p0index3; echo ""; echo "
index 4: ".$p0index4; echo ""; echo "
index 5: ".$p0index5; echo ""; echo "
index 6: ".$p0index6; echo ""; echo "
Jump: ".$p0jump; echo ""; echo "
Link: ".$p0link; echo ""; echo "
Count: ".$p0count; /* temporary incrementing count register on every pass as debugging item */ $p0count = $p0count + 1; $p0count = (string)$p0count; echo ""; echo "
Zero: ".$p0zero; echo ""; echo "
Return Pointer: ".$p0srp; echo ""; echo "
Argument Pointer: ".$p0AP; echo ""; echo "
Frame Pointer: ".$p0FP; echo ""; echo "
Stack Pointer: ".$p0SP; echo ""; echo "
Program Counter: ".$p0PC; echo ""; echo "

Register R0 (MIPS: \$zero): ".$p0R0; echo ""; echo "
Register R1 (MIPS: \$at): ".$p0R1; echo ""; echo "
Register R2 (MIPS: \$v0): ".$p0R2; echo ""; echo "
Register R3 (MIPS: \$v1): ".$p0R3; echo ""; echo "
Register R4 (MIPS: \$a0): ".$p0R4; echo ""; echo "
Register R5 (MIPS: \$a1): ".$p0R5; echo ""; echo "
Register R6 (MIPS: \$a2): ".$p0R6; echo ""; echo "
Register R7 (MIPS: \$a3): ".$p0R7; echo ""; echo "
Register R8 (MIPS: \$t0): ".$p0R8; echo ""; echo "
Register R9 (MIPS: \$t1): ".$p0R9; echo ""; echo "
Register R10 (MIPS: \$t2): ".$p0R10; echo ""; echo "
Register R11 (MIPS: \$t3): ".$p0R11; echo ""; echo "
Register R12 (MIPS: \$t4): ".$p0R12; echo ""; echo "
Register R13 (MIPS: \$t5): ".$p0R13; echo ""; echo "
Register R14 (MIPS: \$t6): ".$p0R14; echo ""; echo "
Register R15 (MIPS: \$t7): ".$p0R15; echo ""; echo "
Register R16 (MIPS: \$s0): ".$p0R16; echo ""; echo "
Register R17 (MIPS: \$s1): ".$p0R17; echo ""; echo "
Register R18 (MIPS: \$s2): ".$p0R18; echo ""; echo "
Register R19 (MIPS: \$s3): ".$p0R19; echo ""; echo "
Register R20 (MIPS: \$s4): ".$p0R20; echo ""; echo "
Register R21 (MIPS: \$s5): ".$p0R21; echo ""; echo "
Register R22 (MIPS: \$s6): ".$p0R22; echo ""; echo "
Register R23 (MIPS: \$s7): ".$p0R23; echo ""; echo "
Register R24 (MIPS: \$t8): ".$p0R24; echo ""; echo "
Register R25 (MIPS: \$t9): ".$p0R25; echo ""; echo "
Register R26 (MIPS: \$k0): ".$p0R26; echo ""; echo "
Register R27 (MIPS: \$k1): ".$p0R27; echo ""; echo "
Register R28 (MIPS: \$gp): ".$p0R28; echo ""; echo "
Register R29 (MIPS: \$sp): ".$p0R29; echo ""; echo "
Register R30 (MIPS: \$fp): ".$p0R30; echo ""; echo "
Register R31 (MIPS: \$ra): ".$p0R31; echo ""; echo "

Register D0: ".$p0D0; echo ""; echo "
Register D1: ".$p0D1; echo ""; echo "
Register D2: ".$p0D2; echo ""; echo "
Register D3: ".$p0D3; echo ""; echo "
Register D4: ".$p0D4; echo ""; echo "
Register D5: ".$p0D5; echo ""; echo "
Register D6: ".$p0D6; echo ""; echo "
Register D7: ".$p0D7; echo ""; echo "

Register A0: ".$p0A0; echo ""; echo "
Register A1: ".$p0A1; echo ""; echo "
Register A2: ".$p0A2; echo ""; echo "
Register A3: ".$p0A3; echo ""; echo "
Register A4: ".$p0A4; echo ""; echo "
Register A5: ".$p0A5; echo ""; echo "
Register A6: ".$p0A6; echo ""; echo "
Register A7: ".$p0A7; echo ""; echo "

Register L0: ".$p0L0; echo ""; echo "
Register L1: ".$p0L1; echo ""; echo "
Register L2: ".$p0L2; echo ""; echo "
Register L3: ".$p0L3; echo ""; echo "
Register L4: ".$p0L4; echo ""; echo "
Register L5: ".$p0L5; echo ""; echo "
Register L6: ".$p0L6; echo ""; echo "
Register L7: ".$p0L7; echo ""; echo "

Register L8: ".$p0L8; echo ""; echo "
Register L9: ".$p0L9; echo ""; echo "
Register L10: ".$p0L10; echo ""; echo "
Register L11: ".$p0L11; echo ""; echo "
Register L12: ".$p0L12; echo ""; echo "
Register L13: ".$p0L13; echo ""; echo "
Register L14: ".$p0L14; echo ""; echo "
Register L15: ".$p0L15; echo ""; echo "
Register L16: ".$p0L16; echo ""; echo "
Register L17: ".$p0L17; echo ""; echo "
Register L18: ".$p0L18; echo ""; echo "
Register L19: ".$p0L19; echo ""; echo "
Register L20: ".$p0L20; echo ""; echo "
Register L21: ".$p0L21; echo ""; echo "
Register L22: ".$p0L22; echo ""; echo "
Register L23: ".$p0L23; echo ""; echo "

Register L24: ".$p0L24; echo ""; echo "
Register L25: ".$p0L25; echo ""; echo "
Register L26: ".$p0L26; echo ""; echo "
Register L27: ".$p0L27; echo ""; echo "
Register L28: ".$p0L28; echo ""; echo "
Register L29: ".$p0L29; echo ""; echo "
Register L30: ".$p0L30; echo ""; echo "
Register L31: ".$p0L31; echo ""; echo "

Register F0: ".$p0F0; echo ""; echo "
Register F1: ".$p0F1; echo ""; echo "
Register F2: ".$p0F2; echo ""; echo "
Register F3: ".$p0F3; echo ""; echo "
Register F4: ".$p0F4; echo ""; echo "
Register F5: ".$p0F5; echo ""; echo "
Register F6: ".$p0F6; echo ""; echo "
Register F7: ".$p0F7; echo ""; echo "
Register F8: ".$p0F8; echo ""; echo "
Register F9: ".$p0F9; echo ""; echo "
Register F10: ".$p0F10; echo ""; echo "
Register F11: ".$p0F11; echo ""; echo "
Register F12: ".$p0F12; echo ""; echo "
Register F13: ".$p0F13; echo ""; echo "
Register F14: ".$p0F14; echo ""; echo "
Register F15: ".$p0F15; echo ""; echo "
Register F16: ".$p0F16; echo ""; echo "
Register F17: ".$p0F17; echo ""; echo "
Register F18: ".$p0F18; echo ""; echo "
Register F19: ".$p0F19; echo ""; echo "
Register F20: ".$p0F20; echo ""; echo "
Register F21: ".$p0F21; echo ""; echo "
Register F22: ".$p0F22; echo ""; echo "
Register F23: ".$p0F23; echo ""; echo "
Register F24: ".$p0F24; echo ""; echo "
Register F25: ".$p0F25; echo ""; echo "
Register F26: ".$p0F26; echo ""; echo "
Register F27: ".$p0F27; echo ""; echo "
Register F28: ".$p0F28; echo ""; echo "
Register F29: ".$p0F29; echo ""; echo "
Register F30: ".$p0F30; echo ""; echo "
Register F31: ".$p0F31; echo ""; echo ""; if ( is_array( $codearray ) ) { echo ""; } ?>

processor 1"; echo "

type: ".$p1type; echo ""; if ( $p1type == "0" ) { echo " (GENERIC)"; } elseif ( $p1type == "A" ) { echo " (Intel 8080)"; } echo "

ACCumulator: ".$p1acc; echo ""; echo "
B register: ".$p1b; echo ""; echo "
C register: ".$p1c; echo ""; echo "
D register: ".$p1d; echo ""; echo "
E register: ".$p1e; echo ""; echo "
HL: ".$p1HL; echo ""; echo "
index X: ".$p1indexx; echo ""; echo "
index Y: ".$p1indexy; echo ""; echo "
index 1: ".$p1index1; echo ""; echo "
index 2: ".$p1index2; echo ""; echo "
index 3: ".$p1index3; echo ""; echo "
index 4: ".$p1index4; echo ""; echo "
index 5: ".$p1index5; echo ""; echo "
index 6: ".$p1index6; echo ""; echo "
Jump: ".$p1jump; echo ""; echo "
Link: ".$p1link; echo ""; echo "
Count: ".$p1count; echo ""; echo "
Zero: ".$p1zero; echo ""; echo "
Return Pointer: ".$p1srp; echo ""; echo "
Argument Pointer: ".$p1AP; echo ""; echo "
Frame Pointer: ".$p1FP; echo ""; echo "
Stack Pointer: ".$p1SP; echo ""; echo "
Program Counter: ".$p1PC; echo ""; echo "

Register R0: ".$p1R0; echo ""; echo "
Register R1: ".$p1R1; echo ""; echo "
Register R2: ".$p1R2; echo ""; echo "
Register R3: ".$p1R3; echo ""; echo "
Register R4: ".$p1R4; echo ""; echo "
Register R5: ".$p1R5; echo ""; echo "
Register R6: ".$p1R6; echo ""; echo "
Register R7: ".$p1R7; echo ""; echo "
Register R8: ".$p1R8; echo ""; echo "
Register R9: ".$p1R9; echo ""; echo "
Register R10: ".$p1R10; echo ""; echo "
Register R11: ".$p1R11; echo ""; echo "
Register R12: ".$p1R12; echo ""; echo "
Register R13: ".$p1R13; echo ""; echo "
Register R14: ".$p1R14; echo ""; echo "
Register R15: ".$p1R15; echo ""; echo "
Register R16: ".$p1R16; echo ""; echo "
Register R17: ".$p1R17; echo ""; echo "
Register R18: ".$p1R18; echo ""; echo "
Register R19: ".$p1R19; echo ""; echo "
Register R20: ".$p1R20; echo ""; echo "
Register R21: ".$p1R21; echo ""; echo "
Register R22: ".$p1R22; echo ""; echo "
Register R23: ".$p1R23; echo ""; echo "
Register R24: ".$p1R24; echo ""; echo "
Register R25: ".$p1R25; echo ""; echo "
Register R26: ".$p1R26; echo ""; echo "
Register R27: ".$p1R27; echo ""; echo "
Register R28: ".$p1R28; echo ""; echo "
Register R29: ".$p1R29; echo ""; echo "
Register R30: ".$p1R30; echo ""; echo "
Register R31: ".$p1R31; echo ""; echo "

Register D0: ".$p1D0; echo ""; echo "
Register D1: ".$p1D1; echo ""; echo "
Register D2: ".$p1D2; echo ""; echo "
Register D3: ".$p1D3; echo ""; echo "
Register D4: ".$p1D4; echo ""; echo "
Register D5: ".$p1D5; echo ""; echo "
Register D6: ".$p1D6; echo ""; echo "
Register D7: ".$p1D7; echo ""; echo "

Register A0: ".$p1A0; echo ""; echo "
Register A1: ".$p1A1; echo ""; echo "
Register A2: ".$p1A2; echo ""; echo "
Register A3: ".$p1A3; echo ""; echo "
Register A4: ".$p1A4; echo ""; echo "
Register A5: ".$p1A5; echo ""; echo "
Register A6: ".$p1A6; echo ""; echo "
Register A7: ".$p1A7; echo ""; echo "

Register L0: ".$p1L0; echo ""; echo "
Register L1: ".$p1L1; echo ""; echo "
Register L2: ".$p1L2; echo ""; echo "
Register L3: ".$p1L3; echo ""; echo "
Register L4: ".$p1L4; echo ""; echo "
Register L5: ".$p1L5; echo ""; echo "
Register L6: ".$p1L6; echo ""; echo "
Register L7: ".$p1L7; echo ""; echo "

Register L8: ".$p1L8; echo ""; echo "
Register L9: ".$p1L9; echo ""; echo "
Register L10: ".$p1L10; echo ""; echo "
Register L11: ".$p1L11; echo ""; echo "
Register L12: ".$p1L12; echo ""; echo "
Register L13: ".$p1L13; echo ""; echo "
Register L14: ".$p1L14; echo ""; echo "
Register L15: ".$p1L15; echo ""; echo "
Register L16: ".$p1L16; echo ""; echo "
Register L17: ".$p1L17; echo ""; echo "
Register L18: ".$p1L18; echo ""; echo "
Register L19: ".$p1L19; echo ""; echo "
Register L20: ".$p1L20; echo ""; echo "
Register L21: ".$p1L21; echo ""; echo "
Register L22: ".$p1L22; echo ""; echo "
Register L23: ".$p1L23; echo ""; echo "

Register L24: ".$p1L24; echo ""; echo "
Register L25: ".$p1L25; echo ""; echo "
Register L26: ".$p1L26; echo ""; echo "
Register L27: ".$p1L27; echo ""; echo "
Register L28: ".$p1L28; echo ""; echo "
Register L29: ".$p1L29; echo ""; echo "
Register L30: ".$p1L30; echo ""; echo "
Register L31: ".$p1L31; echo ""; echo "

Register F0: ".$p1F0; echo ""; echo "
Register F1: ".$p1F1; echo ""; echo "
Register F2: ".$p1F2; echo ""; echo "
Register F3: ".$p1F3; echo ""; echo "
Register F4: ".$p1F4; echo ""; echo "
Register F5: ".$p1F5; echo ""; echo "
Register F6: ".$p1F6; echo ""; echo "
Register F7: ".$p1F7; echo ""; echo "
Register F8: ".$p1F8; echo ""; echo "
Register F9: ".$p1F9; echo ""; echo "
Register F10: ".$p1F10; echo ""; echo "
Register F11: ".$p1F11; echo ""; echo "
Register F12: ".$p1F12; echo ""; echo "
Register F13: ".$p1F13; echo ""; echo "
Register F14: ".$p1F14; echo ""; echo "
Register F15: ".$p1F15; echo ""; echo "
Register F16: ".$p1F16; echo ""; echo "
Register F17: ".$p1F17; echo ""; echo "
Register F18: ".$p1F18; echo ""; echo "
Register F19: ".$p1F19; echo ""; echo "
Register F20: ".$p1F20; echo ""; echo "
Register F21: ".$p1F21; echo ""; echo "
Register F22: ".$p1F22; echo ""; echo "
Register F23: ".$p1F23; echo ""; echo "
Register F24: ".$p1F24; echo ""; echo "
Register F25: ".$p1F25; echo ""; echo "
Register F26: ".$p1F26; echo ""; echo "
Register F27: ".$p1F27; echo ""; echo "
Register F28: ".$p1F28; echo ""; echo "
Register F29: ".$p1F29; echo ""; echo "
Register F30: ".$p1F30; echo ""; echo "
Register F31: ".$p1F31; echo ""; ?>

label is ".$tokenstring[LABELPOS]; } for ($loopvariable = TOKENCOUNTPOS; $loopvariable <= $numtokens; $loopvariable += 1) { echo "
token number ".$loopvariable." is ".$tokenstring[$loopvariable + 1]; } /* if ( ( $displaymemoryflag == TRUE ) AND $memory ) { echo "
"; while( $element = each( $memory ) ) { echo $element [ 'key' ]; echo ' - '; echo $element [ 'value' ]; echo "
"; } } */ /* if ( is_array( $memory ) ) { print_r($memory); } else { echo "
memory is not an array"; } */ if ( is_array( $memory ) ) { echo ""; } if ( is_array( $codearray ) ) { echo "
codearray string is "; $temppcnumber = hexdec($p0PC); /* FOR TESTING */ $placeholder = $temppcnumber - 1; /*temporarily pinning codearray to first position */ echo "
PC = ".$placeholder." "; $numberoftokens = $codearray[$placeholder][TOKENCOUNTPOS]; for ($loopvariable = 0; $loopvariable <= $numberoftokens + 1; $loopvariable += 1) { $nexttokeninarry = $codearray[$placeholder][$loopvariable]; if ( $nexttokeninarray == "" ) { $nexttokeninarray = "NOTOKEN"; } echo "
".$loopvariable." *".$nexttokeninarry."* "; } } ?>
"; /* echo inputted line */ if ( $schoolspecific != "" ) { echo $schoolspecific."
"; } if( $validentry == FALSE ) { echo $errortype; } else /* valid entry */ { echo"OK"; } ?>
"; echo ""; /* prompt line */ echo "P".$currentprocessor.$mode; ?>

if you want to make a tax-deductible donation to the StarTree107 Foundation to support this educational work, contact Dr. Barry at 949-675-5778

manual
introduction
please install your own personal copy of this emulator