如何在ARM中从命令行计算字符串长度?

时间:2018-11-11 23:00:46

标签: assembly arm

我正在尝试获取通过ARM中的命令行传递的字符串的长度-以下代码有效,但随后返回import random class Bug: def __init__(self, number, xPos, yPos, placement, worldXSize=80, worldYSize=80): # the environment self.number = number self.worldXSize = worldXSize self.worldYSize = worldYSize # the bug self.xPos = xPos self.yPos = yPos print("Bug number ", self.number, " has been created at ", self.xPos, ", ", self.yPos) # the action def randomWalk(self): self.xPos += randomMove() self.yPos += randomMove() self.xPos = (self.xPos + self.worldXSize) % self.worldXSize self.yPos = (self.yPos + self.worldYSize) % self.worldYSize # report def reportPosition(self): print("Bug number ", self.number, " moved to X = ", self.xPos, " Y = ", self.yPos) def placement(self): self.xPos = self.xPos % self.worldXSize + randomMove() def randomMove(): return random.randint(-1, 1) 错误:

core dumped

我在做什么错了?

1 个答案:

答案 0 :(得分:1)

您在main的末尾缺少返回指令,因此在函数结束时,CPU只是继续执行内存中的下一个内容。无法预测这将产生什么效果,但是永远不会好!

您也不会弹出您推送的寄存器,您可以在将返回的lr的弹出值直接弹出到pc的同时执行此操作:

POP {r4-r8,pc}
相关问题