本文整理汇总了Python中memory.Memory.sign方法的典型用法代码示例。如果您正苦于以下问题:Python Memory.sign方法的具体用法?Python Memory.sign怎么用?Python Memory.sign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类memory.Memory
的用法示例。
在下文中一共展示了Memory.sign方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: try_argument
# 需要导入模块: from memory import Memory [as 别名]
# 或者: from memory.Memory import sign [as 别名]
def try_argument(self):
if is_instruction(self.line.operation):
addr_part = self.try_addr_part()
# done self.next() !!!
ind_part = self.try_ind_part()
# done self.next() !!!
f_part = self.try_f_part()
# done self.next() !!!
if self.get() is not None:
if self.get_all_before_this() == "":
# this is invalid address: wrong label or something else
raise InvalidAddrError(self.get_all_forward_from_this())
raise UnexpectedStrInTheEndError(
self.get_all_forward_from_this())
if not (abs(addr_part < 4000)):
raise InvalidAddrError(addr_part)
if not (0 <= f_part <= 63):
raise InvalidFieldSpecError(f_part)
# check if field fixed for this instruction and f_part is different from default
if is_field_fixed(self.line.operation) and f_part != \
get_codes(self.line.operation)[1]:
raise FieldFixedError(self.line.operation)
if not (0 <= ind_part <= 6):
raise InvalidIndError(ind_part)
return Memory.sign(addr_part) * (
abs(addr_part) * 64 ** 3 + ind_part * 64 ** 2 + f_part * 64)
elif self.line.operation in ("EQU", "ORIG", "CON", "END"):
res = self.try_w_exp()
# done self.next() !!!
if res is not None:
if self.get() is not None:
raise UnexpectedStrInTheEndError(
self.get_all_forward_from_this())
return res
else:
raise ExpectedWExpError(self.line.argument)
else: # self.line.instruction = "ALF"
res = self.try_alf_word()
if self.look() is not None:
raise UnexpectedStrInTheEndError(self.get_all_after_this())
return res