Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. a)i The ARM Cortex MO microprocessor has four flags, namely N (negative), 4 Z

ID: 2293265 • Letter: 3

Question

3. a)i The ARM Cortex MO microprocessor has four flags, namely N (negative), 4 Z (zero), C (carry) and V (overflow) Explain what each of these flags would indicate if it was set. What is the state of the flags after the execution of the instruction, ADDS 12, rl, r5, when the value held by r5 is OxA4050000 and the value held by rl is 0x9F280000? ii) b) Assume that the following registers initially hold the values given: r4: 0xEOF27D62 r5 0x0001048D r6: 0x3C2A0919 What values are held in registers rl, r2, r3 and r4 after the following ARM Cortex M0 instructions are executed? ii) iii) iv) LSLSrl, 16, #3 REV r2, r6 sUBS r3, r6, r5 EORS r4, r6

Explanation / Answer

a)
i) If flags are set, each represents as --
    N(negative): Result of the operation performed is negative.
    Z(zero): Result of the operation performed is zero.
    C(carry): Operation results in carry.
    V(overflow): Operation causes overflow.

ii) Given r1 : 0x9F280000 r5 : 0xA4050000
     ADDS r2,r1,r5 ; This instruction peforms addition of contents of r1 and r5, stores in r2 and also updates N,Z,C,V flags.
     0x9F280000 + 0xA4050000 = 0x1432D0000 stores in r2.
     As the above addition results in
     Positive number implies 'N' flag is zero.
     Non-zero number implies 'Z' flag is zero.
     Carry implies 'C' flag is set.
     Overflow ( Addition 2 negative numbers resulted in positive number) implies 'V' is set.

b)   Given r4 : 0xE0F27D62
           r5 : 0x0001048D
           r6 : 0x3C2A0919

i) LSLS r1,r6,#3 ; Contents of r6 are logically shifted left by 3 bits with flag update and stored in r1.
     r6: 0x3C2A0919 : 0011 1100 0010 1010 0000 1001 0001 1001
     Shifting it by 3 bits: 1110 0001 0101 0000 0100 1000 1100 1000 = 0xE15048C8
     Hence, contents of r1 : 0xE15048C8

ii) REV r2,r6 ; reversing bytes of r6 and stores in r2.
      r6: 0x3C2A0919 By reversing its bytes gives 0x19092A3C
      Hence, contents of r2 : 0x19092A3C

iii) SUBS r3,r6,r5 ; Subtracts contents of r5 from contents of r6 and stores in r3. Also updates N,V,C,Z flags.
       r6: 0x3C2A0919 r5 : 0x0001048D
       0x3C2A0919 - 0x0001048D = 0x3C29048C
       Hence, contents of r3 : 0x3C29048C

iv) EORS r4,r6 ; Performs bit-wise exclusive OR operation on contents of r6 and r4, stores in r4. Also updates 'N','Z' flags.
      r4: 0xE0F27D62 r6: 0x3C2A0919
      Peforming bit-wise exclusive OR operation on above gives 0xDCD8747B
      Hence, contents of r4: 0xDCD8747B

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote