안녕하세요. 12차 D팀 곽승준이라고 합니다.
어셈블리어 공부 중에 궁금증이 생겨서 문의 드립니다.
제가 공부해서 알고 있는 지식으로 예를 들어
LDR R0, [R1, #4]!
이 명령어는 R1 + 4 주소의 값을 R0으로 로드하고 R1을 R1 + 4 로 갱신하는 동작을 한다고 알고 있습니다.
그런데
LDR R0, [R1], #4
이렇게 써도 동일한 동작을 하는 건가요?
만일 동일한 동작을 한다면 !는 왜 생겨난 건지 궁금합니다.
동일한 동작을 하지 않는다면 LDR R0, [R1, #4] 와 같은 동작을 하는 건지요?
이상입니다. 미리 답변 주시는 분들께 감사 드립니다.
댓글 2
-
geekjun
2015.09.27 01:12
http://clarus.tistory.com/m/post/198 해당 싸이트를 참조하시면 될것 같습니다.LDR R0, [R1, #4]!은 pre-indexed으로 먼저 r1값을 +4 로 업데이트하고 로드 하는 것입니다.R R0, [R1, #4] 은 r1값을 업데이트 하진 않지만 +4 오프셋하고 로드하는 것입니다.LDR R0, [R1], #4 는 post-indexed라고 먼저 r1의 주소값을 로드하고 나서 +4로 업데이트하는 차이가 있네요. -
geekjun
2015.09.27 01:15
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/BABJGHFJ.html
위 싸이트에도 나와있네요
Offset addressing
The offset value is added to or subtracted from the address obtained from the register Rn. The result is used as the address for the memory access. The register Rn is unaltered. The assembly language syntax for this mode is:
[Rn, #offset]
Pre-indexed addressing
The offset value is added to or subtracted from the address obtained from the register Rn. The result is used as the address for the memory access and written back into the register Rn. The assembly language syntax for this mode is:
[Rn, #offset]!
Post-indexed addressing
The address obtained from the register Rn is used as the address for the memory access. The offset value is added to or subtracted from the address, and written back into the register Rn. The assembly language syntax for this mode is:
[Rn], #offset
.