I. What value will be in register r2 after execution of the following instructions? Show your work with the register values after executing each instruction.
MOV r2, #0x0
LDR r1, =0xCF
MOVS r1, r1,
LSR #1
ADC r2, r2, #0
MOVS r1, r1,
LSR #1
ADC r2, r2, #0
II. Assume a 32 bit register holds a data of four bytes as B3B2B1B0. Write a sequence of ARM instruction that takes this data as input and swaps the bytes 0 and 3 so the result would be B0B1B2B3.
III. Which ARM processor mode/modes has the fewest available number of registers available? How many and why??
Answer :- i) The ARM assembly code has been written below-
MOV r2, #0x0 ;r2 = 0
LDR r1, =0xCF ;r1 = 0xCF
MOVS r1, r1, LSR #1 ;r1 = 0x67 and carry flag = 1 i.e lsb of oxCF
ADC r2, r2, #0 ;r2 = r2+0+carry = 0x01
MOVS r1, r1, LSR #1 ;r1 = 0x33 and c = 1
ADC r2, r2, #0 ;r2 = 0x01 + 0x0 + c = 0x02.
Answer :- ii) The ARM assembly code has been written below-(assume r1 holds 4 bit data)
AND r2, r1, #0x01 ;r2 = lsb i.e. B0
AND r3, r1, #0x08 ;r3 = msb i.e. B3
AND r1, r1, #0x06 ;r1 = 0 B2 B1 0
LSL r2, r2, #3 ;r2 = B0 0 0 0
LSR r3, r3, #3 ;r3 = 0 0 0 B3
ORR r2, r2, r3 ;r2 = B0 0 0 B3
ORR r1, r1, r2 ;r1 = B0 B2 B1 B3
Get Answers For Free
Most questions answered within 1 hours.