Is there something special in the instructions ADD (SP plus register, ARM) and SUB (SP minus register)?
I didn't find anything different from the basic ADD (register) and SUB (register) except the documentation:
<Rd> The destination register. If S is specified and <Rd> is the PC, see SUBS PC, LR and related instructions (ARM) on page B9-2012. This register can be SP. If omitted, <Rd> is SP. This register can be the PC, but ARM deprecates using the PC. If S is not specified and <Rd> is the PC, the instruction is a branch to the address calculated by the operation. This is an interworking branch, see Pseudocode details of operations on ARM core registers on page A2-47. ARM deprecates this use of the PC.
<Rd> The destination register. If S is specified and <Rd> is the PC, see SUBS PC, LR and related
instructions (ARM) on page B9-2012. This register can be SP. If omitted, <Rd> is SP. This register
can be the PC, but ARM deprecates using the PC.
If S is not specified and <Rd> is the PC, the instruction is a branch to the address calculated by the
operation. This is an interworking branch, see Pseudocode details of operations on ARM core
registers on page A2-47. ARM deprecates this use of the PC.
Yet in the pseudocode:
(result, carry, overflow) = AddWithCarry(SP, shifted, ‘0’); if d == 15 then ALUWritePC(result); // setflags is always FALSE here
(result, carry, overflow) = AddWithCarry(SP, shifted, ‘0’);
if d == 15 then
ALUWritePC(result); // setflags is always FALSE here
And nothing in the errata.
If Rd is PC, then the result is written into SP, and the program jumps to the address?
With any other register (than PC) as Rd, the Rd is ignored and the result is written into SP?
Hello again,
do you say about the <Rd> description "If omitted, <Rd> is SP"?
It mentions only the assembler syntax.
That is,
ADD SP,#4
is the same as
ADD SP,SP,#4.
If Rd is PC, then the result is written into SP, and the program jumps to the address? With any other register (than PC) as Rd, the Rd is ignored and the result is written into SP?
Regarding the above your comments, I cannot find any back ground.
Are there any misunderstanding?
Best regards,
Yasuhiko Koumoto.
If it wasn't ARM, I'd suspect error in the documentation, but I've learned that with ARM, everything is possible.
Oops, it was always SP that is added to Rm and the result is written to Rd. That makes sense.
There was a misunderstanding - or mis-reading. New pair of glasses don't fix this problem. ;-)
The question still remains, why is it specifically documented.
I copied the description here (bolding is mine):
Hello.
It would be because why the descriptions would relate between ARM and Thumb instructions for one by one.
ARM instructions would be almost symmetric but Thumb instruction is asymmetric.
However, in the specification document, ARM want to describe their instructions such as ARM and Thumb are equivalent.
So, if there is a special description for Thumb instruction, there is a special description for ARM instruction too
whether really needed or not? Just for symmetry in documentation?
My personal opinion is that ARM and Thumb should be described separately.
Current style has too many information.
Probably ARM wants to share the explanation of an instruction behavior.
I agree.
View all questions in Cortex-A / A-Profile forum