Tuesday 15 September 2015

arm - Do integers wrap around in ARMv6 assembly? -


If I start with integer 1 and repeatedly LSL In the value register, overflow integer once, what is the desired behavior? , <1> * 0000000000000000000000000000000001 * / LSL R, # 1 / * 00000000000000000000000000000010 * / / * Repeat 31 times * / LSL R, # 1 / * 100000000000000000000000000000000000 * / < / Code>

On the next LSL, the program should:

  1. Crash
  2. Set R0 back 1
  3. Something else ? V6-M reference book section A2.2.1,

    "integer arithmetic", Subsection "to rotate the shift and operation":

    (B), each bit of bitsing is omitted by a specific number of bits. The zero is transferred to the right end of the bitstring. The bits transferred from the left side of bitsings are discarded, except that the last bit can be prepared as a carry output.

    So it becomes 0 and the carry flag is set.

No comments:

Post a Comment