22 lines
662 B
Python
22 lines
662 B
Python
|
# pylint:disable=W0622
|
||
|
CMDs = ["ldr", "str"]
|
||
|
|
||
|
|
||
|
def ldr(self, operand):
|
||
|
print("从内存的", operand[1], "处加载至寄存器", operand[0])
|
||
|
if int(operand[1]) < len(self.dtMemory):
|
||
|
value = self.dtMemory[int(operand[1])]
|
||
|
self.registers[int(operand[0])] = value
|
||
|
else:
|
||
|
print("ERROR: Attempted to load from invalid memory address.")
|
||
|
|
||
|
|
||
|
def str(self, operand):
|
||
|
# 往内存写入数据
|
||
|
if int(operand[1]) < len(self.dtMemory):
|
||
|
value = self.registers[int(operand[0])]
|
||
|
print(value)
|
||
|
self.dtMemory[int(operand[1])] = value
|
||
|
else:
|
||
|
print("ERROR: Attempted to store to invalid memory address.")
|