Module 2 Exmples
Module 2 Exmples
Module 2 Exmples
Find the content of the registers r0 and r1 after the following instructions are executed in
isolation. Mention if the CPSR register is updated or not.
(i) MOV r0,r1 (ii) MOV r0,r1,LSL #1 (iii) MOVS r0,r1,LSL #1 (iv) MVN r0,r1 (v) MOV r0,r1,LSR #1
(i) (ii)
Pre : r0=0x80000004 Pre: r0=0x00000000
r1=0x80000004 r1=0x80000004 =1000 0000 0000 0000 0000 0000 0000 0100 in binary.
MOV r0,r1 MOV r0,r1,LSL #1 ;After 1 bit logical shift left(LSL), the value is 0000 0000
Post : r0=0x80000004 0000 0000 0000 0000 0000 1000 which is copied to r0.
r1=0x80000004. Post: r0=0x00000008
CPSR is not updated. r1=0x80000004.
CPSR is not updated.
(i) r1=0x02040608=0000 0010 0000 0100 0000 0110 0000 (ii) r1=0x02040608=0000 0010 0000 0100 0000 0110 0000
1000 1000
r2=0x10305070=0001 0000 0011 0000 0101 0000 0111 r2=0x10305070=0001 0000 0011 0000 0101 0000 0111
0000 0000
Hence, r0=0000 0000 0000 0000 0000 0000 0000 Hence, r0=0001 0010 0011 0100 0101 0110 0111
0000=0x00000000 1000=0x12345678
After execution of AND r0,r1,r2 , r0=0x00000000, After execution of ORR r0,r1,r2 , r0=0x12345678,
r1=0x02040608 and r2=0x10305070 r1=0x02040608 and r2=0x10305070
(iii) After execution, r1=0x00000002 and (iv) After execution, r1=0x00000002 and
r2=0x00000002.CPSR is updated (Zero flag is set if Exclusive r2=0x00000002.CPSR is not updated (Zero flag is set if AND of
OR of r1and r2=0). r1and r2=0).
5) If r0=0x00000000, r1=0x00000001, r2=0x00000002 and r3=0x00000003
Find the content of the register r0, r1, r2 and r3 after the following instructions are executed in isolation. Mention if
the CPSR register is updated or not.
(i) MUL r0,r1,r2 (ii) MLA r0,r1,r2,r3 (iii) UMULL r0,r1,r2,r3
(i) (ii)
Pre: r0=0x00000000 Pre: r0=0x00000000
r1=0x00000001 r1=0x00000001
r2=0x00000002 r2=0x00000002
r3=0x00000003 r3=0x00000003
MUL r0,r1,r2 ; r0=r1*r2 MLA r0,r1,r2,r3 ; , r0=r1*r2+r3
Post: r0=0x00000002 Post: r0=0x00000005
r1=0x00000001 r1=0x00000001
r2=0x00000002 r2=0x00000002
r3=0x00000003 r3=0x00000003
(iii)
Pre: r0=0x00000000
r1=0x00000001
r2=0x00000002
r3=0x00000003
UMULL r0,r1,r2,r3 ; [r0,r1]=r2*r3
Post: r0=0x00000006, r1=0x00000000, r2=0x00000002 and r3=0x00000003
6) If r0=0x00000000, r1=0x00090000
mem32[0x00090000]=0x01010101 and mem32[00090004]=0x02020202
Find the content of the register r0, r1 after the following instructions are executed in isolation.
(i) LDR r0,[r1,#4] (ii) LDR r0,[r1,#4]! (iii) LDR r0,[r1],#4
(i) (ii) After the execution, r0=0x02020202 and r1=0x00090004
Pre: r0=0x00000000
r1=0x00090000
mem32[0x00090000]=0x01010101
mem32[00090004]=0x02020202
LDR r0,[r1,#4]
Post: r0=0x02020202
r1=0x00090000