viewSim.html

viewSim.html — HTML, 45 kB (46.935 bytes)

Dateiinhalt

<html><title>Cpu Simulator</title>
<script type="text/javascript">

// speed
var simSpeed = 1000;
// states
var reset = 1;
var isRun = 0;
var prgSel = -1

// signals
var s = new Array(26);
// text markers
var busChanged = 0;
var akkuChanged = 0;
var aluChanged = 0;
var xChanged = 0;
var pcChanged = 0;
var spChanged = 0;
var opCodeChanged = 0;
var abChanged = 0;
var dbChanged = 0;
var flagsChanged = 0;
// registers & bus value

var bus = 0xff;
var akku = 0xFF;
var x = 0;
var pc = 0xFF;
var sp = 0xFF;
var opCode = 0x00;
var ab = 0xFF;
var db = 0xFF;
var upCnt = 0;
var carry = 0;
var zero = 0;
var sign = 0;
var alucarry = 0;
var aluzero = 0;
var alusign = 0;
var aluop = 0;
var alu = 0;
var currentOp = "RST";
var lastPc = 0;
// helpstrings
var subs1 = "<p><span class=\"smallfont\" style=\"position: absolute; left: 1; top: 1; z-index: 2\"><img src=\"http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/";
var subs2 = ".png\" border=\"0\"></span></p>";

function DecToHex(Value,Digits) {
  var sHex = "";
  var d;
  for (var i=Digits-1;i>=0;i--) {
     d=(Value>>i*4) & 15;
     if (d<10)   sHex+=String.fromCharCode(48+d); else
       sHex+= String.fromCharCode(55+d);
  }
  return sHex;
}
function RegValue(Value){
  return DecToHex(Value,2);
}
function ShowValue(id,value,changed) {
  if (changed)
		  document.getElementById(id).style.color="#FF0000";
	    else 
		  document.getElementById(id).style.color="#0000A0";
	  document.getElementById(id).firstChild.nodeValue = RegValue(value);	  
}
function update(){
      var neu = "";
	  
	  for (i=0;i<15;i++)
        if (s[i] == 1)
         neu += subs1 + "s" + i + subs2;
      for (i=20;i<26;i++)
        if (s[i] == 1)
         neu += subs1 + "s" + i + subs2;
      if (s[16] == 1|| s[17] == 1 || s[18] == 1 || s[19] == 1)
         neu += subs1 + "s16" + subs2;
      if (reset == 1)
         neu += subs1 + "reset" + subs2;
      
      if (neu == "") {
		 tempNode = document.getElementById("imagetree").firstChild;
		 if (tempNode)
		   document.getElementById("imagetree").removeChild(tempNode);
	  }
      else
		document.getElementById("imagetree").innerHTML = neu;
	  // Show values && change markers 
	  ShowValue("Bus",bus,busChanged);
	  ShowValue("Akku",akku,akkuChanged);
	  ShowValue("X",x,xChanged);
	  ShowValue("PC",pc,pcChanged);
	  ShowValue("SP",sp,spChanged);
	  ShowValue("OpCode",opCode,opCodeChanged);
	  ShowValue("AB",ab,abChanged);
	  ShowValue("DB",db,dbChanged);
	  ShowValue("Alu",alu,aluChanged);
	  busChanged = 0;
	  akkuChanged = 0;
	  xChanged = 0;
      pcChanged = 0;
      spChanged = 0;
      opCodeChanged = 0;
      abChanged = 0;
      dbChanged = 0;
      document.getElementById("OpCodeStr").firstChild.nodeValue = DissAssemble(opCode);
	  document.getElementById("upCnt").firstChild.nodeValue = DecToHex(upCnt,1);	  
	  document.getElementById("up").firstChild.nodeValue = DecToHex(carry<<13|zero<<12|sign<<11|upCnt<<8|opCode,4);	  
	  document.getElementById("operation").firstChild.nodeValue  = currentOp;
	  document.getElementById("operation2").value = currentOp;
	  document.getElementById("Acontrol").value = DecToHex(akku,2);
	  document.getElementById("Xcontrol").value = DecToHex(x,2);
	  document.getElementById("PCcontrol").value = DecToHex(pc,2);
	  document.getElementById("SPcontrol").value = DecToHex(sp, 2);
	  var fstr = "";
	  if (zero == 1)
	    fstr = "Z";
	  if (sign == 1)
	    fstr+= "S";
	  if (carry == 1)
	    fstr+="C";
	  document.getElementById("Fcontrol").value = fstr;
	  var alustr = "";
    if (s[20] == 1)
    { // arithmetik
      switch(aluop)
      {
          case 0: alustr = "F = 0"; break;
          case 1: alustr = "F = 1"; break;    
          case 2: alustr = "F = A+B"; break;    // add A,OP
          case 3: alustr = "F = A+B+1"; break; // adc 
          case 4: alustr = "F = A-B"; break;    // sub A,OP 
          case 5: alustr = "F = A-B-1"; break; // sbc A,OP
          case 6: alustr = "F = B-A"; break;    // sub OP,A 
          case 7: alustr = "F = B-A+1"; break; // sbc OP,A
          case 8: alustr = "F = A+1"; break;      // inc A
          case 9: alustr = "F = A-1"; break;      // dec A
          case 10: alustr = "F = -A"; break;        // not A
          case 11: alustr = "F = A"; break;
      }
    } else
    { // logic
      switch(aluop)
      {
          case 0: alustr = "F = 0"; break;
          case 1: alustr = "F = 1"; break;    
          case 2: alustr = "F = A|B"; break;    // or A,OP
          case 3: alustr = "F = A&B"; break;    // and A, OP
          case 4: alustr = "F = A^B"; break;    // xor A,OP 
          case 5: alustr = "F = ~A"; break;         // neg A
          case 6: alustr = "F = A<<1"; break;         // shl A
          case 7: alustr = "F = A>>1"; break;         // shr A
          case 8: alustr = "F = A ROL 1"; break;         // rol A
          case 9: alustr = "F = A ROR 1"; break;         // ror A
      }
    }
    document.getElementById("AluOp").firstChild.nodeValue = alustr;
	  document.getElementById("Flags").firstChild.nodeValue = fstr;
    GenerateStackInfo();
	GenerateMemInfo();      

	// view Program
	switch(parseInt(prgSel)) 
	{   
	case -1: GenerateAssembler();GenerateMicrocode();  break;
	case 0: break;
	case 1: BspCount();break;
	case 2: BspMul();break;
	case 3: BspFib();break;
	case 4: BspFibIter();break;
	case 5: BspFak();break;
	}
	prgSel = 0;
	document.getElementById("runbutton").checked=isRun;
	document.getElementById("runbutton2").checked=isRun;
	

	  
}
function Run() {
    isRun = !isRun;
    
    if (isRun) 
		window.setTimeout("EngineTimer()", 200);

}
// Microprogramm
var maxSize = 60;
var upCode = new Array(maxSize*8);
// Reset
upCode[0x0] = "";
upCode[0x1] = "S3;S4";
upCode[0x2] = "S1;S3;S6;S8;S10;S20";
upCode[0x3] = "S13;S15;S21;S22";
upCode[0x4] = "S0;S15;S25";
upCode[0x5] = "";
upCode[0x6] = "";
upCode[0x7] = "";
// hlt
upCode[0x8] = "S25";
// nop
upCode[0x10] = "";
upCode[0x11] = "";
upCode[0x12] = "";
upCode[0x13] = "";
upCode[0x14] = "S3;S5";
upCode[0x15] = "S1;S3";
upCode[0x16] = "S13;S15";
upCode[0x17] = "S0;S15;";
// jump
upCode[0x18] = "S5;S3";
upCode[0x19] = "S3;S1";
upCode[0x1a] = "S13;S15;";
upCode[0x1b] = "S2";
upCode[0x1c] = "S3;";
upCode[0x1d] = "S1";
upCode[0x1e] = "S13;S15;";
upCode[0x1f] = "S0;S15;";
// mov a
upCode[0x20] = "S5;S3";
upCode[0x21] = "S3;S1";
upCode[0x22] = "S15;S13";
upCode[0x23] = "S10;S15";
upCode[0x24] = "S3;S5";
upCode[0x25] = "S1;S3";
upCode[0x26] = "S13;S15";
upCode[0x27] = "S0;S15;";
// add a
upCode[0x28] = "S5;S3";
upCode[0x29] = "S3;S1";
upCode[0x2a] = "S11;S13;S15;S17;S20;";
upCode[0x2b] = "S10;S11;S13;S15;S17;S20;S21";
upCode[0x2c] = "S5;S3";
upCode[0x2d] = "S1;S3";
upCode[0x2e] = "S13;S15";
upCode[0x2f] = "S0;S15;";
// sub a
upCode[0x30] = "S5;S3";
upCode[0x31] = "S3;S1";
upCode[0x32] = "S11;S13;S15;S18;S20;";
upCode[0x33] = "S10;S11;S13;S15;S18;S20;S21";
upCode[0x34] = "S5;S3";
upCode[0x35] = "S1;S3";
upCode[0x36] = "S13;S15";
upCode[0x37] = "S0;S15;";
// neg a
upCode[0x38] = "S12;S11;"
upCode[0x39] = "S11;S17;S19;S20";
upCode[0x3a] = "S11;S13;S15;S17;S19;S20;";
upCode[0x3b] = "S11;S10;S15;S17;S19;S20;S21";
upCode[0x3c] = "S5;S3";
upCode[0x3d] = "S1;S3";
upCode[0x3e] = "S13;S15";
upCode[0x3f] = "S0;S15;";
// not a
upCode[0x40] = "S12;S11;"
upCode[0x41] = "S11;S16;S18";
upCode[0x42] = "S11;S13;S16;S18;";
upCode[0x43] = "S11;S10;S15;S16;S18;S21";
upCode[0x44] = "S5;S3";
upCode[0x45] = "S1;S3";
upCode[0x46] = "S13;S15";
upCode[0x47] = "S0;S15;";
// inc a
upCode[0x48] = "S12;S11;"
upCode[0x49] = "S11;S19;S20";
upCode[0x4a] = "S11;S13;S19;S20;";
upCode[0x4b] = "S11;S10;S19;S20;S21";
upCode[0x4c] = "S5;S3";
upCode[0x4d] = "S1;S3";
upCode[0x4e] = "S13;S15";
upCode[0x4f] = "S0;S15;";
// dec a
upCode[0x50] = "S12;S11;"
upCode[0x51] = "S11;S16;S19;S20";
upCode[0x52] = "S11;S13;S16;S19;S20";
upCode[0x53] = "S11;S10;S16;S19;S20;S21";
upCode[0x54] = "S5;S3";
upCode[0x55] = "S1;S3";
upCode[0x56] = "S13;S15";
upCode[0x57] = "S0;S15;";
// and a
upCode[0x58] = "S5;S3"
upCode[0x59] = "S1;S3";
upCode[0x5a] = "S13;S15;S16;S17;";
upCode[0x5b] = "S11;S10;S15;S16;S17;S21";
upCode[0x5c] = "S5;S3";
upCode[0x5d] = "S1;S3";
upCode[0x5e] = "S13;S15";
upCode[0x5f] = "S0;S15;";
// or a
upCode[0x60] = "S5;S3" 
upCode[0x61] = "S1;S3" 
upCode[0x62] = "S13;S15;S17";
upCode[0x63] = "S11;S10;S15;S17;S21";
upCode[0x64] = "S5;S3";
upCode[0x65] = "S1;S3";
upCode[0x66] = "S13;S15";
upCode[0x67] = "S0;S15";
// xor a
upCode[0x68] = "S5;S3" 
upCode[0x69] = "S1;S3" 
upCode[0x6a] = "S13;S15;S18";
upCode[0x6b] = "S11;S10;S15;S18;S21";
upCode[0x6c] = "S5;S3";
upCode[0x6d] = "S1;S3";
upCode[0x6e] = "S13;S15";
upCode[0x6f] = "S0;S15";
// shl a
upCode[0x70] = "S12;S11;"
upCode[0x71] = "S11;S17;S18";
upCode[0x72] = "S11;S13;S17;S18;";
upCode[0x73] = "S11;S10;S15;S17;S18;S21";
upCode[0x74] = "S5;S3";
upCode[0x75] = "S1;S3";
upCode[0x76] = "S13;S15";
upCode[0x77] = "S0;S15;";
// shr a
upCode[0x78] = "S12;S11;"
upCode[0x79] = "S11;S16;S17;S18";
upCode[0x7a] = "S11;S13;S16;S17;S18;";
upCode[0x7b] = "S11;S10;S15;S16;S17;S18;S21";
upCode[0x7c] = "S5;S3";
upCode[0x7d] = "S1;S3";
upCode[0x7e] = "S13;S15";
upCode[0x7f] = "S0;S15;";
// rol a
upCode[0x80] = "S12;S11;"
upCode[0x81] = "S11;S19";
upCode[0x82] = "S11;S13;S19;";
upCode[0x83] = "S11;S10;S15;S19;S21";
upCode[0x84] = "S5;S3";
upCode[0x85] = "S1;S3";
upCode[0x86] = "S13;S15";
upCode[0x87] = "S0;S15;";
// ror a
upCode[0x88] = "S12;S11;"
upCode[0x89] = "S11;S16;S19";
upCode[0x8a] = "S11;S13;S16;S19;";
upCode[0x8b] = "S11;S10;S15;S16;S19;S21";
upCode[0x8c] = "S5;S3";
upCode[0x8d] = "S1;S3";
upCode[0x8e] = "S13;S15";
upCode[0x8f] = "S0;S15;";
// sbc a
upCode[0x90] = "S5;S3";
upCode[0x91] = "S3;S1";
upCode[0x92] = "S11;S13;S15;C16;S17;S20;";
upCode[0x93] = "S10;S11;S13;S15;C16;S18;S20;S21";
upCode[0x94] = "S5;S3";
upCode[0x95] = "S1;S3";
upCode[0x96] = "S13;S15";
upCode[0x97] = "S0;S15;";
// adc a
upCode[0x98] = "S5;S3";
upCode[0x99] = "S3;S1";
upCode[0x9a] = "S11;S13;S15;C16;S17;S20;";
upCode[0x9b] = "S10;S11;S13;S15;C16;S17;S20;S21";
upCode[0x9c] = "S5;S3";
upCode[0x9d] = "S1;S3";
upCode[0x9e] = "S13;S15";
upCode[0x9f] = "S0;S15";
// mov A,X
upCode[0xa0] = "S7";
upCode[0xa1] = "S7;S10";
upCode[0xa2] = "";
upCode[0xa3] = "";
upCode[0xa4] = "S5;S3";
upCode[0xa5] = "S1;S3";
upCode[0xa6] = "S13;S15";
upCode[0xa7] = "S0;S15";
// mov A,[X]
upCode[0xa8] = "S7";
upCode[0xa9] = "S7;S1";
upCode[0xaa] = "S13;S15";
upCode[0xab] = "S10;S15";
upCode[0xac] = "S5;S3";
upCode[0xad] = "S1;S3";
upCode[0xae] = "S13;S15";
upCode[0xaf] = "S0;S15";
// mov X, A
upCode[0xb0] = "S12";
upCode[0xb1] = "S6";
upCode[0xb2] = "";
upCode[0xb3] = "";
upCode[0xb4] = "S3;S5";
upCode[0xb5] = "S1;S3";
upCode[0xb6] = "S13;S15";
upCode[0xb7] = "S0;S15";
// mov [X],A
upCode[0xb8] = "S7";
upCode[0xb9] = "S7;S1";
upCode[0xba] = "S12";
upCode[0xbb] = "S12;S13;S14";
upCode[0xbc] = "S3;S5";
upCode[0xbd] = "S1;S3";
upCode[0xbe] = "S13;S15";
upCode[0xbf] = "S0;S15";
// mov x
upCode[0xc0] = "S5;S3";
upCode[0xc1] = "S3;S1";
upCode[0xc2] = "S15;S13";
upCode[0xc3] = "S6;S15";
upCode[0xc4] = "S3;S5";
upCode[0xc5] = "S1;S3";
upCode[0xc6] = "S13;S15";
upCode[0xC7] = "S0;S15;";
// mov X,[X]
upCode[0xc8] = "S7";
upCode[0xc9] = "S7;S1";
upCode[0xca] = "S13;S15";
upCode[0xcb] = "S6;S15";
upCode[0xcc] = "S5;S3";
upCode[0xcd] = "S1;S3";
upCode[0xce] = "S13;S15";
upCode[0xcf] = "S0;S15";
// mov X,[A]
upCode[0xd0] = "S10";
upCode[0xd1] = "S10;S1";
upCode[0xd2] = "S13;S15";
upCode[0xd3] = "S6;S15";
upCode[0xd4] = "S5;S3";
upCode[0xd5] = "S1;S3";
upCode[0xd6] = "S13;S15";
upCode[0xd7] = "S0;S15";
// push a
upCode[0xd8] = "S9";
upCode[0xd9] = "S9;S1";
upCode[0xda] = "S12";
upCode[0xdb] = "S12;S13;S14;S22";
upCode[0xdc] = "S5;S3";
upCode[0xdd] = "S1;S3";
upCode[0xde] = "S13;S15";
upCode[0xdf] = "S0;S15";
// pop a
upCode[0xe0] = "S9;S22;S23";
upCode[0xe1] = "S9;S1";
upCode[0xe2] = "S13;S15";
upCode[0xe3] = "S15;S10";
upCode[0xe4] = "S5;S3";
upCode[0xe5] = "S1;S3";
upCode[0xe6] = "S13;S15";
upCode[0xe7] = "S0;S15";
// push x
upCode[0xe8] = "S9";
upCode[0xe9] = "S9;S1";
upCode[0xea] = "S7";
upCode[0xeb] = "S7;S13;S14;S22";
upCode[0xec] = "S5;S3";
upCode[0xed] = "S1;S3";
upCode[0xee] = "S13;S15";
upCode[0xef] = "S0;S15";
// pop x
upCode[0xf0] = "S9;S22;S23";
upCode[0xf1] = "S9;S1";
upCode[0xf2] = "S13;S15";
upCode[0xf3] = "S15;S6";
upCode[0xf4] = "S5;S3";
upCode[0xf5] = "S1;S3";
upCode[0xf6] = "S13;S15";
upCode[0xf7] = "S0;S15";
// dec x
upCode[0xf8] = "S24";
upCode[0xf9] = "S7;S16;S17;S19;S20;";
upCode[0xfa] = "S7;S16;S17;S19;S20;S21";
upCode[0xfb] = "";
upCode[0xfc] = "S5;S3";
upCode[0xfd] = "S1;S3";
upCode[0xfe] = "S13;S15";
upCode[0xff] = "S0;S15";
// inc x
upCode[0x100] = "S24;S23";
upCode[0x101] = "S7;S16;S17;S19;S20;";
upCode[0x102] = "S7;S16;S17;S19;S20;S21";
upCode[0x103] = "";
upCode[0x104] = "S5;S3";
upCode[0x105] = "S1;S3";
upCode[0x106] = "S13;S15";
upCode[0x107] = "S0;S15";
// cmp a
upCode[0x108] = "S5;S3";
upCode[0x109] = "S3;S1";
upCode[0x10a] = "S11;S13;S15;S18;S20;";
upCode[0x10b] = "S11;S13;S15;S18;S20;S21";
upCode[0x10c] = "S5;S3";
upCode[0x10d] = "S1;S3";
upCode[0x10e] = "S13;S15";
upCode[0x10f] = "S0;S15;";
// cmpz x
upCode[0x110] = "";
upCode[0x111] = "S7";
upCode[0x112] = "S7;S16;S17;S19;S20;";
upCode[0x113] = "S7;S16;S17;S19;S20;S21";
upCode[0x114] = "S5;S3";
upCode[0x115] = "S1;S3";
upCode[0x116] = "S13;S15";
upCode[0x117] = "S0;S15;";
// cmp a,x
upCode[0x118] = "";
upCode[0x119] = "S7";
upCode[0x11a] = "S7;S18;S20;";
upCode[0x11b] = "S7;S18;S20;S21";
upCode[0x11c] = "S5;S3";
upCode[0x11d] = "S1;S3";
upCode[0x11e] = "S13;S15";
upCode[0x11f] = "S0;S15;";
// cmpz a
upCode[0x120] = "";
upCode[0x121] = "S12";
upCode[0x122] = "S12;S18;S19;S20;";
upCode[0x123] = "S12;S18;S19;S20;S21";
upCode[0x124] = "S5;S3";
upCode[0x125] = "S1;S3";
upCode[0x126] = "S13;S15";
upCode[0x127] = "S0;S15;";
// call 
upCode[0x128] = "S9;S5";
upCode[0x129] = "S9;S1";
upCode[0x12a] = "S3;S13;S14";
upCode[0x12b] = "S3;S22;S1";
upCode[0x12c] = "S13;S15";
upCode[0x12d] = "S1;S2;S15";
upCode[0x12e] = "S13;S15";
upCode[0x12f] = "S0;S15";
// ret
upCode[0x130] = "S9;S22;S23";
upCode[0x131] = "S9;S1";
upCode[0x132] = "S13;S15";
upCode[0x133] = "S15;S2";
upCode[0x134] = "S5;S3";
upCode[0x135] = "S1;S3";
upCode[0x136] = "S13;S15";
upCode[0x137] = "S0;S15";
// dec SP
upCode[0x138] = "S22";
upCode[0x139] = "S9;S16;S17;S19;S20;";
upCode[0x13a] = "S9;S16;S17;S19;S20;S21";
upCode[0x13b] = "";
upCode[0x13c] = "S5;S3";
upCode[0x13d] = "S1;S3";
upCode[0x13e] = "S13;S15";
upCode[0x13f] = "S0;S15";
// inc SP
upCode[0x140] = "S22;S23";
upCode[0x141] = "S9;S16;S17;S19;S20;";
upCode[0x142] = "S9;S16;S17;S19;S20;S21";
upCode[0x143] = "";
upCode[0x144] = "S5;S3";
upCode[0x145] = "S1;S3";
upCode[0x146] = "S13;S15";
upCode[0x147] = "S0;S15";
// mov [const],a 
upCode[0x148] = "S5;S3";
upCode[0x149] = "S1";
upCode[0x14a] = "S13;S15";
upCode[0x14b] = "S1;S12;S13;S14";
upCode[0x14c] = "S3;S5;";
upCode[0x14d] = "S1";
upCode[0x14e] = "S13;S15";
upCode[0x14f] = "S0;S15";
// mov a,[const] 
upCode[0x150] = "S5;S3;S1";
upCode[0x151] = "S1;S13;S15;S5";
upCode[0x152] = "S1";
upCode[0x153] = "S13;S15";
upCode[0x154] = "S10;S3";
upCode[0x155] = "S1";
upCode[0x156] = "S13;S15";
upCode[0x157] = "S0;S15";
// mov [const],x 
upCode[0x158] = "S5;S3";
upCode[0x159] = "S1";
upCode[0x15a] = "S13;S15";
upCode[0x15b] = "S1;S7;S13;S14";
upCode[0x15c] = "S3;S5;";
upCode[0x15d] = "S1";
upCode[0x15e] = "S13;S15";
upCode[0x15f] = "S0;S15";
// mov x,[const] 
upCode[0x160] = "S5;S3;S1"
upCode[0x161] = "S1;S13;S15;S5";
upCode[0x162] = "S1";
upCode[0x163] = "S13;S15";
upCode[0x164] = "S6;S3";
upCode[0x165] = "S1";
upCode[0x166] = "S13;S15";
upCode[0x167] = "S0;S15";
// add a.x
upCode[0x168] = "";
upCode[0x169] = "S7";
upCode[0x16a] = "S7;S11;S17;S20;";
upCode[0x16b] = "S7;S10;S11;S17;S20;S21";
upCode[0x16c] = "S5;S3";
upCode[0x16d] = "S1;S3";
upCode[0x16e] = "S13;S15";
upCode[0x16f] = "S0;S15;";
// sub a,x
upCode[0x170] = "";
upCode[0x171] = "S7";
upCode[0x172] = "S7;S11;S18;S20;";
upCode[0x173] = "S7;S10;S11;S18;S20;S21";
upCode[0x174] = "S5;S3";
upCode[0x175] = "S1;S3";
upCode[0x176] = "S13;S15";
upCode[0x177] = "S0;S15;";
// adc a,x
upCode[0x178] = "";
upCode[0x179] = "S7";
upCode[0x17a] = "S7;S11;C16;S17;S20;";
upCode[0x17b] = "S7;S10;S11;C16;S17;S20;S21";
upCode[0x17c] = "S5;S3";
upCode[0x17d] = "S1;S3";
upCode[0x17e] = "S13;S15";
upCode[0x17f] = "S0;S15";
// sbc a,x
upCode[0x180] = "";
upCode[0x181] = "S7";
upCode[0x182] = "S7;S11;C16;S17;S20;";
upCode[0x183] = "S7;S10;S11;C16;S18;S20;S21";
upCode[0x184] = "S5;S3";
upCode[0x185] = "S1;S3";
upCode[0x186] = "S13;S15";
upCode[0x187] = "S0;S15;";

// jz 
upCode[0x188] = "S5;S3";
upCode[0x189] = "S3;S1";
upCode[0x18a] = "S13;S15";
upCode[0x18b] = "Z2;";
upCode[0x18c] = "S3;U5";
upCode[0x18d] = "S1;S3";
upCode[0x18e] = "S13;S15";
upCode[0x18f] = "S0;S15";
// jnz 
upCode[0x190] = "S5;S3";
upCode[0x191] = "S3;S1";
upCode[0x192] = "S13;S15";
upCode[0x193] = "U2;";
upCode[0x194] = "S3;Z5;";
upCode[0x195] = "S1;S3";
upCode[0x196] = "S13;S15";
upCode[0x197] = "S0;S15";
// jc 
upCode[0x198] = "S5;S3";
upCode[0x199] = "S3;S1";
upCode[0x19a] = "S13;S15";
upCode[0x19b] = "C2;";
upCode[0x19c] = "S3;I5";
upCode[0x19d] = "S1;S3";
upCode[0x19e] = "S13;S15";
upCode[0x19f] = "S0;S15";
// jnc 
upCode[0x1a0] = "S5;S3";
upCode[0x1a1] = "S3;S1";
upCode[0x1a2] = "S13;S15";
upCode[0x1a3] = "I2;";
upCode[0x1a4] = "S3;C5;";
upCode[0x1a5] = "S1;S3";
upCode[0x1a6] = "S13;S15";
upCode[0x1a7] = "S0;S15";
// js 
upCode[0x1a8] = "S5;S3";
upCode[0x1a9] = "S3;S1";
upCode[0x1aa] = "S13;S15";
upCode[0x1ab] = "N2;";
upCode[0x1ac] = "S3;P5";
upCode[0x1ad] = "S1;S3";
upCode[0x1ae] = "S13;S15";
upCode[0x1af] = "S0;S15";
// jns 
upCode[0x1b0] = "S5;S3";
upCode[0x1b1] = "S3;S1";
upCode[0x1b2] = "S13;S15";
upCode[0x1b3] = "P2;";
upCode[0x1b4] = "S3;N5;";
upCode[0x1b5] = "S1;S3";
upCode[0x1b6] = "S13;S15";
upCode[0x1b7] = "S0;S15";

/// memory & programm
var memory = new Array(256);
memory[0x00] = 4; // move
memory[0x01] = 0x7;  
memory[0x02] = 5; // add
memory[0x03] = 5;  
memory[0x04] = 3; // jmp  
memory[0x05] = 2;  
memory[0x06] = 1;  

function selectSignals(upSel){
    // reset all signals

    for (i=0;i<26;i++)
      s[i]=0;
    // now set according to microcode
    if (upCode[upSel]) {
       var upCodeStr = upCode[upSel];
       var sarr=upCodeStr.split(";");
       i=0;
       if (sarr)
       while(sarr[i]) 
       {
          if (sarr[i].charAt(0)=="C" && !carry) { // carry
             i++;
             continue;
         }
          if (sarr[i].charAt(0)=="N" && !sign) { // negative
             i++;
             continue;
         }
         if (sarr[i].charAt(0)=="Z" && !zero) { // zero
             i++;
             continue;
         }
         if (sarr[i].charAt(0)=="U" && zero) { // unequal zero
             i++;
             continue;
         }
         if (sarr[i].charAt(0)=="P" && sign) { // positive
             i++;
             continue;
         }
         if (sarr[i].charAt(0)=="I" && carry) { // inside
             i++;
             continue;
         }
         index = parseInt(sarr[i].substring(1));
         s[index]=1;
         i++;
        }
          
    } 

}
var memIndex = new Array(256);

function EngineTimer() {

    var upSel;
    var i;
    if (reset) {
      opCode = 0;
      opCodeChanged = 1;
      upCnt = 0;
      reset = 0;
      for (i=0;i<256;i++)
      {
	      memIndex[i]=null;
	      var n = document.getElementById("progc"+i);
	      if (n!=null)
		      n.innerHTML = " ";	
	  }      
    }
    
    upSel = opCode*8+upCnt;
    selectSignals(upSel);
	// do logic
	if (s[0] == 1) { opCode = bus; opCodeChanged = 1; }
	if (s[1] == 1) { ab = bus; abChanged = 1; }
	if (s[2] == 1) { pc = bus; pcChanged = 1; }
	if (s[4] == 1) { pc = 0; pcChanged = 1; }
	if (s[6] == 1) { x = bus; xChanged = 1; }
	if (s[8] == 1) { sp = bus; spChanged = 1; }
	if (s[10] == 1) { if (s[11]==0) akku = bus ; akkuChanged = 1; }
	if (s[5] == 1) { pc++; pcChanged = 1; }
	if (s[22] == 1) { if (s[23]==1) sp++; else sp--; spChanged = 1; }
	if (s[24] == 1) { if (s[23]==1) x++; else x--; xChanged = 1; }
	if (s[3] == 1) { bus = pc; busChanged = 1; }
	if (s[7] == 1) { bus = x; busChanged = 1; }
	if (s[9] == 1) { bus = sp; busChanged = 1; }
	if (s[12] == 1) { bus = akku; busChanged = 1; }
	if (s[13] == 1) {if (s[14] == 1) { db = bus; memory[ab] = db; 
	   if (ab!=sp && ab!=sp+1){
	          memIndex[ab]=1;
	       }
		}  db = memory[ab] & 0xFF; dbChanged = 1; }
	if (s[15] == 1) { bus = db; busChanged = 1; }
	if (s[21] == 1) { carry = alucarry; zero = aluzero; sign = alusign; flagsChanged = 1; }
    // alu
    aluop = s[16]|s[17]<<1|s[18]<<2|s[19]<<3;
    if (s[20] == 1)
    { // arithmetik
      switch(aluop)
      {
          case 0: alu = 0; break;
          case 1: alu = 1; break;    
          case 2: alu = akku + bus; break;    // add A,OP
          case 3: alu = akku + bus +1; break; // adc 
          case 4: alu = akku - bus; break;    // sub A,OP 
          case 5: alu = akku -(bus +1); break; // sbc A,OP
          case 6: alu = bus - akku; break;    // sub OP,A 
          case 7: alu = akku - (bus +1); break; // sbc OP,A
          case 8: alu = akku + 1; break;      // inc A
          case 9: alu = akku - 1; break;      // dec A
          case 10: alu = -akku; break;        // not A
          case 11: alu = bus; break;        //  cmpz X
          case 12: alu = akku; break;        //  cmpz A
      }
    } else
    { // logic
      switch(aluop)
      {
          case 0: alu = 0; break;
          case 1: alu = 1; break;    
          case 2: alu = akku | bus; break;    // or A,OP
          case 3: alu = akku & bus; break;    // and A, OP
          case 4: alu = akku ^ bus; break;    // xor A,OP 
          case 5: alu = ~akku; break;         // neg A
          case 6: alu = akku << 1; break;         // shl A
          case 7: alu = akku >> 1; break;         // shr A
          case 8: alu = ((akku & 128) >>7) || akku << 1; break;         // rol A
          case 9: alu = ((akku & 1)<<7) || akku  >> 1; break;         // ror A
      }
    }
    if (alu>255||alu<0)
       alucarry = 1; else alucarry = 0;
    alu &=0xFF;
    if (alu==0)
       aluzero = 1; else aluzero = 0;
        
    if (alu>127)
       alusign = 1; else alusign = 0;
	if (s[10] == 1) { if (s[11]==1) akku = alu; }
    


	update();
	if (s[25]==1)
	   upCnt = 0; 
	else
	   upCnt++;
    if (upCnt > 7)
      upCnt = 0; 
     if (upCnt == 0)
     {
		// here we know the next operation
        currentOp = DecToHex(pc,2)+":"+DissAssemble(opCode)+DissOperands(opCode,pc+1);
        // ToDo: move from here to update()
        var n = document.getElementById("progc"+lastPc);
        if (n!=null)
          n.innerHTML = " ";
        lastPc = pc;
        n = document.getElementById("progc"+lastPc);
        if (n!=null)
          n.innerHTML = "&lt;&lt;";
        
          
       }
    if (isRun) 
		window.setTimeout("EngineTimer()", simSpeed);

}

var mnemonics = new Array(maxSize);
var ops = new Array(maxSize);

mnemonics[0] = "RST";
mnemonics[1] = "HLT";
mnemonics[2] = "NOP";
mnemonics[3] = "JMP";  ops[3]=1;
mnemonics[4] = "MOV A";ops[4]=2;
mnemonics[5] = "ADD A";ops[5]=2;
mnemonics[6] = "SUB A";ops[6]=2;
mnemonics[7] = "NEG A";
mnemonics[8] = "NOT A";
mnemonics[9] = "INC A";
mnemonics[10] = "DEC A";
mnemonics[11] = "AND A";ops[11]=2;
mnemonics[12] = "OR A";ops[12]=2;
mnemonics[13] = "XOR A";ops[13]=2;
mnemonics[14] = "SHL A";
mnemonics[15] = "SHR A";
mnemonics[16] = "ROL A";
mnemonics[17] = "ROR A";
mnemonics[18] = "SBC A";ops[18]=2;
mnemonics[19] = "ADC A";ops[19]=2;
mnemonics[20] = "MOV A,X";
mnemonics[21] = "MOV A,[X]";
mnemonics[22] = "MOV X, A";
mnemonics[23] = "MOV [X], A";
mnemonics[24] = "MOV X";ops[24]=2;
mnemonics[25] = "MOV X,[X]";
mnemonics[26] = "MOV X,[A]";
mnemonics[27] = "PUSH A";
mnemonics[28] = "POP A";
mnemonics[29] = "PUSH X";
mnemonics[30] = "POP X";
mnemonics[31] = "DEC X";
mnemonics[32] = "INC X";
mnemonics[33] = "CMP A";ops[33]=2;
mnemonics[34] = "CMPZ X";
mnemonics[35] = "CMP A,X";
mnemonics[36] = "CMPZ A";
mnemonics[37] = "CALL";ops[37]=1;
mnemonics[38] = "RET";
mnemonics[39] = "DEC SP";
mnemonics[40] = "INC SP";
mnemonics[41] = "MOV [Const],A";ops[41]=3;
mnemonics[42] = "MOV A,[Const]";ops[42]=3;
mnemonics[43] = "MOV [Const],X";ops[43]=3;
mnemonics[44] = "MOV X,[Const]";ops[44]=3;
mnemonics[45] = "ADD A,X";
mnemonics[46] = "SUB A,X";;
mnemonics[47] = "ADC A,X";
mnemonics[48] = "SBC A,X";
mnemonics[49] = "JZ";ops[49]=1;
mnemonics[50] = "JNZ";ops[50]=1;
mnemonics[51] = "JC"; ops[51] = 1;
mnemonics[52] = "JNC"; ops[52] = 1;
mnemonics[53] = "JS"; ops[53] = 1;
mnemonics[54] = "JNS"; ops[54] = 1;

function BspCount() {
    isRun = 0;
    reset = 1;
    memory[0x00] = 24; // movx
    memory[0x01] = 0x0a;
    memory[0x02] = 9; // inc a;  
    memory[0x03] = 31; // dec a;  
    memory[0x04] = 50; // jnz
    memory[0x05] = 02; // jnz
    memory[0x06] = 01; // hlt
    memory[0x07] = null;
    memory[0x08] = null;
    memory[0x09] = null;
    memory[0x0a] = null;
    memory[0x0b] = null;
    memory[0x0c] = null;
    GenerateAssembler();
}

function BspFibIter() {
    isRun = 0;
    reset = 1;
    memory[0x00] = 24; // movx
	memory[0x01] = 0x5;  
	memory[0x02] = 37; // call 0x05  
	memory[0x03] = 5;
	memory[0x04] = 1;
	memory[0x05] = 4;  // mov a,1
	memory[0x06] = 1;
	memory[0x07] = 31; // dec x
	memory[0x08] = 49; // jz
	memory[0x09] = 0x18;
	memory[0x0a] = 41;  // mov [0xe0],a
	memory[0x0b] = 0xe0; // jz ziel
	memory[0x0c] = 31; // dec X
	memory[0x0d] = 49;  // jz
	memory[0x0e] = 0x18
	memory[0x0f] = 29; // push x
	memory[0x10] = 44; // mov x,[0xe0]
	memory[0x11] = 0xe0;
	memory[0x12] = 41;  // mov [0xe0],a
	memory[0x13] = 0xe0; // jz ziel
	memory[0x14] = 45; // add a,x 
	memory[0x15] = 30; // pop x
	memory[0x16] = 3;  // jmp
	memory[0x17] = 0x0c;
	memory[0x18] = 38; // ret
	for (i=0x19;i<0xFF;i++)
		memory[i] = null;
	GenerateAssembler();
}

function BspFib() {
    isRun = 0;
    reset = 1;
    memory[0x00] = 24; // movx
	memory[0x01] = 0x5;  
	memory[0x02] = 37; // call 0x05  
	memory[0x03] = 5;
	memory[0x04] = 1;
	memory[0x05] = 20; // mov a,x
	memory[0x06] = 33; //cmp a,1
	memory[0x07] = 1;
	memory[0x08] = 49; // jz
	memory[0x09] = 0x1a;  // jz
	memory[0x0a] = 33; //cmp a,2
	memory[0x0b] = 2;
	memory[0x0c] = 49; // jz
	memory[0x0d] = 0x1a;  // jz
	memory[0x0e] = 31; // dec x
	memory[0x0f] = 29; // push x
	memory[0x10] = 37; // call
	memory[0x11] = 5; // fib
	memory[0x12] = 30; // pop x
	memory[0x13] = 27; // push a
	memory[0x14] = 31; // dec x
	memory[0x15] = 37; // call
	memory[0x16] = 5; // fib
	memory[0x17] = 30; // pop x
	memory[0x18] = 45; // add a,x
	memory[0x19] = 38 // ret
	memory[0x1a] = 4; // mov a
	memory[0x1b] = 1; // mov a
	memory[0x1c] = 38 // ret
	memory[0x1d] = null;
	memory[0x1e] = null;
	memory[0x1f] = null;
	for (i=0x20;i<0xFF;i++)
		memory[i] = null;
	
	GenerateAssembler();
}

function BspMul() {
    isRun = 0;
    reset = 1;
    memory[0x00] = 4; // mova
	memory[0x01] = 0x7;  
	memory[0x02] = 24; // movx
	memory[0x03] = 0x10;  
	memory[0x04] = 37; // call 0x07  
	memory[0x05] = 7;
	memory[0x06] = 1;
	memory[0x07] = 34 // cmpz x
	memory[0x08] = 49; // jz
	memory[0x09] = 0x19;
	memory[0x0a] = 36; // cmpz a
	memory[0x0b] = 49; // jz
	memory[0x0c] = 0x19;
	memory[0x0d] = 41; //mov [const],a;
	memory[0x0e] = 0xe0;
	memory[0x0f] = 31; // dec x;
	memory[0x10] = 49;// jz
	memory[0x11] = 0x19;
	memory[0x12] = 29; // push x;
	memory[0x13] = 44  // mov x,[const]
	memory[0x14] = 0xe0; 
	memory[0x15] = 45 //add a,x
	memory[0x16] = 30 // pop x;
	memory[0x17] = 3 // jmp 
	memory[0x18] = 0xf
	memory[0x19] = 38 // ret
	for (i=0x1a;i<0xFF;i++)
		memory[i] = null;
	GenerateAssembler();
}

function BspFak() {
    isRun = 0;
    reset = 1;
    memory[0x00] = 4; // mova
	memory[0x01] = 0x5;  
	memory[0x02] = 37; // call
	memory[0x03] = 0x1a;  
	memory[0x04] = 1; // call 0x07  
	memory[0x05] = 1;
	memory[0x06] = 1;
	memory[0x07] = 34 // cmpz x
	memory[0x08] = 49; // jz
	memory[0x09] = 0x19;
	memory[0x0a] = 36; // cmpz a
	memory[0x0b] = 49; // jz
	memory[0x0c] = 0x19;
	memory[0x0d] = 41; //mov [const],a;
	memory[0x0e] = 0xe0;
	memory[0x0f] = 31; // dec x;
	memory[0x10] = 49;// jz
	memory[0x11] = 0x19;
	memory[0x12] = 29; // push x;
	memory[0x13] = 44  // mov x,[const]
	memory[0x14] = 0xe0; 
	memory[0x15] = 45 //add a,x
	memory[0x16] = 30 // pop x;
	memory[0x17] = 3 // jmp 
	memory[0x18] = 0xf
	memory[0x19] = 38 // ret
	memory[0x1a] = 33 // cmpa,1
	memory[0x1b] = 1 // cmpa,1
	memory[0x1c] = 50 // JNZ
	memory[0x1d] = 0x1f // JNZ
	memory[0x1e] = 38 // ret	
	memory[0x1f] = 27; // push a
	memory[0x20] = 10; // dec a
	memory[0x21] = 37; // call 
	memory[0x22] = 0x1a; // fak
	memory[0x23] = 30    // pop x
	memory[0x24] = 37    // call
	memory[0x25] = 7    // call mul
	memory[0x26] = 38    // ret

	for (i=0x27;i<0xFF;i++)
		memory[i] = null;
	GenerateAssembler();
}

function BspSel(sel) {
  prgSel=sel;
  if (!isRun)
    Run();
}

function DissAssemble(opCode) {
   return mnemonics[opCode];
} 

function DissOperands(opCode,mem) {
    var str = "";
    if (memory[mem]!=null)
	switch(ops[parseInt(opCode)])
	{
	   case 1: str = " "+DecToHex(memory[mem],2); break; 
	   case 2: str = ", "+DecToHex(memory[mem],2); break; 
	   case 3: str = ", "+DecToHex(memory[mem],2); break; 
	   default: break;
	}
   	return str;
} 


function DoReset() {
  
  reset = 1;
  
  update();
}
function DoStep() {
  
  isRun = 0;
  EngineTimer();
}

var ass = "<form name=\"prg"
var ass0 = "\"><input type=\"button\" value=\"+\" title=\"Add new assembler command\" onclick=\"AddLine(";
var ass1 = ")\"/><input type=\"text\" value=\"";
var ass2 = "\" readonly=\"true\" size=\"2\"/>\n<select name=\"sel\" onChange=\"storeAssembler(";
var ass3 = ",prg"
var ass4 = ".sel.value)\">";
var options = "<option selected value=\"";
var options0 = "<option value=\"";
var options1 = "\">";
var options2 = "</option>";
var ass5 = "</select><input type=\"text\" value=\""
var ass6 = "\" name=\"Operands\" onchange=\"storeOperand(";
var ass7 = ", prg"
var ass8 = ".Operands.value)\" /><input type=\"button\" value=\"-\" title=\"delete this assembler command\" onclick=\"DeleteLine(";
var ass9 = ")\"/><span id=\"progc"
var ass10 = "\"> </span></form>";

function storeAssembler(line, opCode)
{
    var hasOperands = DissOperands(memory[line],line+1)!="";
    memory[line] = parseInt(opCode);
    var hasNowOperands = DissOperands(memory[line],line+1)!="";
    if (hasOperands != hasNowOperands) { 
        // change memory
        if (hasOperands) {
           memory[line+1] = 1;
           DeleteLine(line+1);
        } 
        if (hasNowOperands) {
           memory[line] = 1;
           AddLine(line,1);
           memory[line] = parseInt(opCode);
        } 
    }
    GenerateAssembler();
}

function storeOperand(line, value)
{
  while (value.charAt(0)==" ")
     value = value.substring(1); 
  while (value.charAt(0)==",")
     value = value.substring(1); 
  while (value.charAt(0)==" ")
     value = value.substring(1); 
   memory[line+1] = parseInt(value,16);
    GenerateAssembler();
}

function DeleteLine(line)
{
   if (DissOperands(memory[line],line+1)!="")
   { // with operand
      var i=line+2;
      while(memory[i])
      {
          memory[i-2]=memory[i];
          i++;
      }
      memory[i-2] = null; 
      memory[i-1] = null; 
   } else
   {
      var i=line+1;
      while(memory[i])
      {
          memory[i-1]=memory[i];
          i++;
      }
      memory[i-1] = null; 
   }
   if (memory[0]==null)
     memory[0]=1;
   GenerateAssembler();
}

function AddLine(line)
{

   memory.push();
   var i=memory.length-2;
   while(i>line)
   {
      memory[i+1]=memory[i];
      i--;
   }
   if (DissOperands(memory[line],line+1)!="")
	   memory[line+2] = 1;
	 else
	   memory[line+1] = 1;
   
    GenerateAssembler();
   
}


function GenerateAssembler(){
  var i=0;
  var neu="";
  var op = "";
  while (memory[i] != null) {
     neu += ass+i+ass0+i+ass1+DecToHex(i,2)+ass2+i+ass3+i+ass4;
     var j=1;
     while (mnemonics[j]) {
       if (memory[i] == j)
		    neu+=options + j + options1 + mnemonics[j] + options2;
		  else  
		    neu+=options0 + j + options1 + mnemonics[j] + options2;
       j++;
     }
     pc = i;
     op = DissOperands(memory[i],i+1);
     if (op!="")
     {
	     neu += ass5+op+ass6+i+ass7+i+ass8+i+ass9+i+ass10;
	     i++;
	 } else
	     neu += ass5+ass6+i+ass7+i+ass8+i+ass9+i+ass10;
     
     i++;
  }

   document.getElementById("assProg").innerHTML = neu;

}

var mic = "<form name=\"micro\">OpCode: <select name=\"sel\" onChange=\"editMicroCode(micro.sel.value)\">";
var mic1 = "</select><p>";
var mic2 = "<div><input type=\"text\" size=\"48\" id=\"micro";
var mic3 = "\" onchange=\"storeUpCode("
var mic4 = ")\" /><input type=\"button\" title=\"Show states\" value=\"Show\" onclick=\"showUpCode(";
var mic5 = ")\" /></div>"
var mic6 = "</form>"

function editMicroCode(opCode) {
     var index=8*opCode;
     
     for (i=0;i<8;i++)
	     document.getElementById("micro"+i).value = upCode[index+i];
}

function showUpCode(line){
  var index=8*document.micro.sel.value+line;
  isRun = 0;
  selectSignals(index); 
  update();
}
function storeUpCode(line){
  var index=8*document.micro.sel.value+line;
  upCode[index] = document.getElementById("micro"+line).value;
}

var stack0 = "&lt;Empty&gt";
var stack1 = "<form>"
var stack2 = "<div><input type=\"text\" size=\"2\" readonly value=\"";
var stack3 = "\">[";
var stack4 = "]</div>";
var stack5 = "</form>";
var mem0 = "&lt;not used&gt";


function GenerateStackInfo() {
    var neu = "";
    if (sp < 0)
        sp = 256 + sp; 
    if (sp == 255 || sp == 0) {
        neu = stack0;
    } else {
        neu = stack1;
        var i = 256;
        for (i = sp + 1; i < 256; i++) {
          
            neu += stack2 + DecToHex(memory[i],2) + stack3 + DecToHex(i,2)+stack4;
        }
        neu += stack5;
    }
    document.getElementById("stack").innerHTML = neu;
}
function GenerateMemInfo() {
    var neu = stack1;
    var changed = 0;
    for (i = 0; i <256; i++) {
          
          if (memIndex[i]!=null) {
            neu += stack2 + DecToHex(memory[i],2) + stack3 + DecToHex(i,2)+stack4;
            changed = 1;
			}
        }
        neu += stack5;
      if (changed == 0)
      neu = mem0;
    document.getElementById("mem").innerHTML = neu;
}

function GenerateMicrocode(){

     var neu = mic;
     var j=0;
     while (mnemonics[j]) {
 	    neu+=options0 + j + options1 + mnemonics[j] + options2;
        j++;
     }
     neu +=mic1;
     for (i=0;i<8;i++)
       neu+= mic2+i+mic3+i+mic4+i+mic5;
     neu+=mic6;
     document.getElementById("microCode").innerHTML = neu;
     editMicroCode(0);
}

function setSpeed(step)
{
  switch(parseInt(step))
  {
      case 0: simSpeed = 50;  break;
      case 1: simSpeed = 300; break;
      case 2: simSpeed = 600; break;
      case 3: simSpeed = 1000;break;
      case 4: simSpeed = 1500;break;
  }
}
window.setTimeout("update()", 750);
</script>

<body style="font-family:Arial">
<form name="ctrl2"><input type="checkbox" name="run" value="0"  title ="Run" onclick="Run()"/>Run
      <input type="button" title="Reset" value="Reset" size="5" onclick="DoReset()" />
      <input type="button" title="Step" value="->" size="5" onclick="DoStep();ctrl2.run.checked=0;" /></form>

<div id="imgagebase"><p><span style="position: absolute; left: 1; top: 1; z-index: 1" width="960" height="720" ><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/cpu.png" border="0"></span></p></div>
<div id="imagetree"><p><span style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/reset.png" border="0"></span></p>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/reset.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s0.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s1.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s2.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s2.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s3.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s4.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s5.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s6.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s7.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s8.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s9.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s10.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s11.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s12.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s13.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s14.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s15.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s16.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s16.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s16.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s16.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s20.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s21.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s22.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s23.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s24.png" border="0"></span>
<span class="smallfont" style="position: absolute; left: 1; top: 1; z-index: 2"><img src="http://www.unibw.de/etti6/pawelczak/lehre/GDI/cpu-simulator/s25.png" border="0"></span>
</div>
<p><span style="position: absolute; left: 100; top: 64; z-index: 3"><h3 id="Bus">00</h3></span></p>
<p><span style="position: absolute; left: 220; top: 220; z-index: 3"><h3 id="Akku" style="color:#0000A0">00</h3></span></p>
<p><span style="position: absolute; left: 220; top: 310; z-index: 3"><h3 id="X" style="color:#0000A0"> 00</h3></span></p>
<p><span style="position: absolute; left: 220; top: 400; z-index: 3"><h3 id="PC" style="color:#0000A0">00</h3></span></p>
<p><span style="position: absolute; left: 220; top: 490; z-index: 3"><h3 id="SP" style="color:#0000A0">00</h3></span></p>
<p><span style="position: absolute; left: 370; top: 174; z-index: 3"><h3 id="Alu" style="color:#0000A0">00</h3></span></p>
<p><span style="position: absolute; left: 520; top: 134; z-index: 3"><h3 id="AluOp" style="color:#0000A0">F = 0</h3></span></p>
<p><span style="position: absolute; left: 520; top: 21; z-index: 3"><h3 id="Flags" style="color:#0000A0">Z</h3></span></p>
<p><span style="position: absolute; left: 30; top: 620; z-index: 3"><h3 id="DB" style="color:#0000A0">00</h3></span></p>
<p><span style="position: absolute; left: 360; top: 620; z-index: 3"><h3 id="AB" style="color:#0000A0">00</h3></span></p>
<p><span style="position: absolute; left: 670; top: 530; z-index: 3"><h3 id="OpCode" style="color:#0000A0">00</h3></span></p>
<p><span style="position: absolute; left: 820; top: 530; z-index: 3"><h3 id="OpCodeStr" style="color:#0000A0">XX</h3></span></p>
<p><span style="position: absolute; left: 840; top: 426; z-index: 3"><h3 id="upCnt" style="color:Red">0</h3></span></p>
<p><span style="position: absolute; left: 690; top: 400; z-index: 3"><h3 id="up" style="color:#0000A0">0000</h3></span></p>
<p><span style="position: absolute; left: 4; top: 4; z-index: 4">
<form name="ctrl2"><input id="runbutton2" type="checkbox" name="run" value="0"  title ="Run" onclick="Run()"/>Run
      <input type="button" title="Reset" value="Reset" size="5" onclick="DoReset()" />
      <input type="button" title="Step" value=">>" size="5" onclick="DoStep();" /> <p id="operation">RST</p>  </form>
</span>
<span style="position: absolute; left: 630; top: 801; z-index: 5">Stack=
<div id="stack">&lt;Empty&gt
</div></span>
<span style="position: absolute; left: 730; top: 801; z-index: 5">Memory=
<div id="mem">&lt;Empty&gt
</div></span>

<p><span style="position: absolute; left: 4; top: 750; z-index: 4"><H3>Control</H3></H3></span>
<span style="position: absolute; left: 4; top: 800; z-index: 4">
<form name="ctrl"><center>Decoding: <input id="operation2" readonly style="color:#0000A0" value="RST" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</center>
<input id="runbutton" type="checkbox" name="run" value="0"  title ="Run" onclick="Run()"/>Run
      <input type="button" title="Reset" value="Reset" size="5" onclick="DoReset()" />
      <input type="button" title="Single Step" value=">>" size="5" onclick="DoStep();" />
	  <select name="speed" onchange="setSpeed(ctrl.speed.value)">
	  <option value="0">Maximum</option>
	  <option value="1">Fast</option>
	  <option value="2">Medium</option>
	  <option value="3" selected>Steady</option>;
	  <option value="4">Slow</option>
	  </select> A=<input type="text" readonly id="Acontrol" size="2" value="00" /> 
	  X=<input type="text" readonly id="Xcontrol" size="2" value="00" /> 
	  F=<input type="text" readonly id="Fcontrol" size="2" value="00" />    
	  PC=<input type="text" readonly id="PCcontrol" size="2" value="00" />    
	  SP=<input type="text" readonly id="SPcontrol" size="2" value="00" />
      </form>

<H3>Assembler Program</H3>
<div id="assProg">prg
</div>
<H3>Microprogram</H3>
<div id="microCode">micro
</div>
<hr /><i>(c) 2006-2010 by Dieter Pawelczak</i>

</span></p>
<p><span style="position: absolute; left: 410; top: 870; z-index: 4"><H4>Beispiele</H4></span>
<p><span style="position: absolute; left: 410; top: 920; z-index: 4"><a href="javascript:BspSel(1);">Z�hlen</a></span>
<p><span style="position: absolute; left: 410; top: 940; z-index: 4"><a href="javascript:BspSel(2);">Multiplikation</a></span>
<p><span style="position: absolute; left: 410; top: 960; z-index: 4"><a href="javascript:BspSel(3);">Fibonnaci-Zahlen (rekursiv)</a></span>
<p><span style="position: absolute; left: 410; top: 980; z-index: 4"><a href="javascript:BspSel(4);">Fibonnaci-Zahlen (iterativ)</a></span>
<p><span style="position: absolute; left: 410; top: 1000; z-index: 4"><a href="javascript:BspSel(5);">Fakult�t (rekursiv)</a></span>

</body></html>