aboutsummaryrefslogtreecommitdiff
path: root/components/microprogram.py
diff options
context:
space:
mode:
Diffstat (limited to 'components/microprogram.py')
-rw-r--r--components/microprogram.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/components/microprogram.py b/components/microprogram.py
index fb0e589..4543de1 100644
--- a/components/microprogram.py
+++ b/components/microprogram.py
@@ -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):