Assembly 了解组装过程的最佳方法是什么?
为了挑战自我,我正在努力学习组装。我使用IDA找到了这个函数:Assembly 了解组装过程的最佳方法是什么?,assembly,arm,Assembly,Arm,为了挑战自我,我正在努力学习组装。我使用IDA找到了这个函数: Question - (void)setCorrectAnswerIndex:(int) ; void __cdecl -[Question setCorrectAnswerIndex:](struct Question *self, SEL, int) __Question_setCorrectAnswerIndex__ MOV R1, #(_OBJC_IVAR_$_Question.correctAns
Question - (void)setCorrectAnswerIndex:(int)
; void __cdecl -[Question setCorrectAnswerIndex:](struct Question *self, SEL, int)
__Question_setCorrectAnswerIndex__
MOV R1, #(_OBJC_IVAR_$_Question.correctAnswerIndex - 0x5C750) ; int correctAnswerIndex;
ADD R1, PC ; int correctAnswerIndex;
LDR R1, [R1] ; int correctAnswerIndex;
STR R2, [R0,R1]
BX LR
; End of function -[Question setCorrectAnswerIndex:]
我只是很难弄清楚它是如何工作的,以及如何修改它。因此setCorrectAnswerIndex将始终设置为静态数字或其他内容。让我们看看为什么查看编译的高级代码不是一个很好的学习方法。从手臂装配的角度来看,发生的情况如下:
- 将常数移到寄存器R1中
- 将当前程序计数器添加到该计数器,以创建从该代码到程序映像的其他部分的相对偏移量的地址
- 将存储在该地址的任何值加载到R1中
- 将R2中保存的值存储到R0+R1生成的地址
- 通过分支到链接寄存器中保存的地址返回调用方