Debug MBR register

This commit is contained in:
Loic GUEGAN 2018-09-01 16:49:12 +02:00
parent 6ac0692116
commit d58349763a
4 changed files with 21 additions and 20 deletions

View file

@ -45,7 +45,7 @@ class Microprogram:
"""
Execute next opcode
"""
opcode=self.c["MBR"] # Get loaded OpCode
opcode=self.c["MBRU"] # Get loaded OpCode (/!\ We used MBRU not MBR because MBR is signed)
if opcode==ijvm["NOP"]: # NOP
pass
elif opcode==ijvm["BIPUSH"]: # BIPUSH
@ -135,16 +135,23 @@ class Microprogram:
self.c["H"]=self.c["MDR"]
self.c["MDR"]=self.c["MBR"]+self.c["H"]
self.wr()
elif opcode==ijvm["GOTO"]:
self.fetch();self.c["PC"]+=1 # Fetch first byte
self.c["OPC"]=self.c["PC"]-1
self.c["H"]=self.c["MBR"]<<8
self.fetch();self.c["PC"]+=1 # Fetch second byte
self.c["H"]=self.c["MBRU"]|self.c["H"]
self.c["PC"]=self.c["OPC"]+self.c["H"]
elif opcode==ijvm["OUT"]:
self.fetch();self.c["PC"]+=1 # Fetch byte to push in MBR
print(str(chr(self.c["MBR"])),end="")
print(str(chr(self.c["MBRU"])),end="") # MBRU because no char which are negative
elif opcode==ijvm["HALT"]:
return(1)
else:
if opcode in ijvm:
print("Instruction {} not yet implemented.".format(ijvm[opcode]))
else:
raise RuntimeError("Instruction {} not found".format(opcode))
raise RuntimeError("Instruction {} not found on address {}".format(opcode,self.c["PC"]-1))
return(0)
def dump(self):