aboutsummaryrefslogtreecommitdiff
path: root/components/microprogram.py
diff options
context:
space:
mode:
authorLoic GUEGAN <loic.guegan@yahoo.fr>2018-09-01 10:19:06 +0200
committerLoic GUEGAN <loic.guegan@yahoo.fr>2018-09-01 10:19:06 +0200
commit739548d99f3450b5def909f98ad65faa3509699a (patch)
treeb18b20260b5032327361e834ae3b5d53857c7e03 /components/microprogram.py
parent84de7cd481662167745131b95c78442a7ff45048 (diff)
Add opcodes
Diffstat (limited to 'components/microprogram.py')
-rw-r--r--components/microprogram.py32
1 files changed, 30 insertions, 2 deletions
diff --git a/components/microprogram.py b/components/microprogram.py
index e1b81a0..fb0e589 100644
--- a/components/microprogram.py
+++ b/components/microprogram.py
@@ -86,7 +86,7 @@ class Microprogram:
self.c["MAR"]=self.c["SP"]
self.c["H"]=self.c["TOS"]
self.rd()
- self.c["TOS"]=(self.c["MDR"] and self.c["H"])
+ self.c["TOS"]=(self.c["MDR"] & self.c["H"])
self.c["MDR"]=self.c["TOS"]
self.wr()
elif opcode==ijvm["IOR"]:
@@ -94,7 +94,7 @@ class Microprogram:
self.c["MAR"]=self.c["SP"]
self.c["H"]=self.c["TOS"]
self.rd()
- self.c["TOS"]=(self.c["MDR"] or self.c["H"])
+ self.c["TOS"]=(self.c["MDR"] | self.c["H"])
self.c["MDR"]=self.c["TOS"]
self.wr()
elif opcode==ijvm["SWAP"]:
@@ -107,6 +107,34 @@ class Microprogram:
self.c["MAR"]=self.c["SP"]-1
self.wr()
self.c["TOS"]=self.c["H"]
+ elif opcode==ijvm["ILOAD"]:
+ self.fetch();self.c["PC"]+=1 # Fetch local variable to push onto the stack
+ self.c["H"]=self.c["LV"]
+ self.c["MAR"]=self.c["MBRU"]+self.c["H"]
+ self.rd()
+ self.c["SP"]+=1
+ self.c["MAR"]=self.c["SP"]
+ self.wr()
+ self.c["TOS"]=self.c["MDR"]
+ elif opcode==ijvm["ISTORE"]:
+ self.fetch();self.c["PC"]+=1 # Fetch local variable offset where to store
+ self.c["H"]=self.c["LV"]
+ self.c["MAR"]=self.c["MBRU"]+self.c["H"]
+ self.c["MDR"]=self.c["TOS"]
+ self.wr()
+ self.c["SP"]-=1
+ self.c["MAR"]=self.c["SP"]
+ self.rd()
+ self.c["TOS"]=self.c["MDR"]
+ elif opcode==ijvm["IINC"]:
+ self.fetch();self.c["PC"]+=1 # Fetch local variable offset to inc
+ self.c["H"]=self.c["LV"]
+ self.c["MAR"]=self.c["MBRU"]+self.c["H"]
+ self.rd()
+ self.fetch();self.c["PC"]+=1 # Fetch inc value
+ self.c["H"]=self.c["MDR"]
+ self.c["MDR"]=self.c["MBR"]+self.c["H"]
+ self.wr()
elif opcode==ijvm["OUT"]:
self.fetch();self.c["PC"]+=1 # Fetch byte to push in MBR
print(str(chr(self.c["MBR"])),end="")