Incorrect translation of LDR pseudo instruction

Asked by Dan Lewis on 2017-04-12

I've discovered that the LDR pseudo instruction doesn't work as expected. My understanding is that the instruction:

      LDR R0,=constant // where "constant" is a number

Should be replaced by one of the following, depending on the value of the constant:

      MOV R0,constant
      MOVW R0,constant // may also be written MOV.W R0,constant
      MVN R0,~constant
      LDR R0,memref // where the constant has been stored separately in memory

None of these translations should modify the flags. Yet, for small positive constants as in:

       LDR R0,=1

It gets translated into:

       MOVS R0,1

which modifies the flags.

In the ARM documentation at http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0489i/Babbfdih.html, under the heading "LDR in Thumb code", it says:

"The LDR pseudo-instruction never generates a 16-bit flag-setting MOV instruction. "

Dan

Question information

Language:
English Edit question
Status:
Open
For:
GNU ARM Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
2017-04-12
Last reply:

Can you help with this problem?

Provide an answer of your own, or ask Dan Lewis for more information if necessary.

To post a message you must log in.