IT 209 Summer 2019 Practise Exam

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

A

Name:

Roll #:

Time: 1 hour
Total Marks: 50

NOTE: THE ANSWERS SHOULD BE WRITTEN IN THE QUESTION PAPER ITSELF. Please do all
your rough work in the answer sheet. Don’t use pencil to fill the answers.

1. AREA examcode ,CODE,READONLY


[2 marks]
ENTRY
LDR r1,label
LDMIA r1,{r2-r12}
Label DCD 1,2,3,4,5,6,7,8,9,10
END
Write down the values loaded into all the registers from r0-r12.

2. At what address, r1 is stored?


[1 mark]
LDR r2,=0x5012
STR r1,[r2]

3. What will be the values of different registers after the execution of the following code? Also
state if there are any errors (if any, rewrite the correct code and give values of registers).
Assume address for ‘label’ is 0x20.
[2 marks]
AREA prog, CODE, READWRITE
ENTRY
MOV R1, #0x5000;
MOV R2, =Label;
loop LDR R3, [R2];
LDR R4, [R2, #8];
CMP R4, R3;
BLT loop;
MOV R5, R3;

Label DCB 0x2, 0x3, 0x4, 0x5

END

4. Memory is shown below:


[1 mark]

Address Addr + 0 Addr + 1 Addr + 2 Addr + 3


0x200 0x00 0x00 0x00 0x06
0x204 0x00 0x00 0x00 0xFC
0x208 0x00 0x00 0x00 0x03
0x20c 0x00 0x00 0x00 0xFF
R10 = 0x210;
What is the contents of r3 after LDMDB r10, {ro-r3} executes, in a big-endian memory system?

5. What is the output of the following set of instructions? Write all the register and memory values
when the below set of instructions is executed.
[2 marks]
LDR r13,=label
LDMIA r13!,{R1-R7}
MOV r0,r13
STMDB r0!,{R1-R7}
LDMED r0!,{R2-R7}
Label DCB 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20

6. What will be the values of all the registers used after the following code execution? Assume Big-
endian system.
[2 marks]

MOV R0, #1;


MOV R1, #2;
MOV R2, #3;
MOV R4, #4;
MOV R7, #5;
LDR R9, =0x5000;
STMIA R9, {R4, R0-R2, R7};
LDMDB R9, {R3, R10, R5-R6, R11};

7. What is the output of the following code snippet?


[1 mark]
LDR r1, Mask
Mask DCD 0x5F:ROL:3

8. Swap only 1 Byte values in memory and register using only 1 instruction.
[1 mark]
9. DCW instruction is used in a program as shown below. Write a code sequence to load the value
0x30 (stored in the array) in register R 5 . Use minimum number of instructions.
[2 marks]
Lable1 DCW 0x10, 0x20, 0x30, 0x40

10. Use a directive to assign register r6 to a name ‘label’.


[1 mark]

11. What are the values of each register used in the program? Assume a big-endian system.
[2 marks]
LDR r1,=0xABCDEFAB
LDR r8,=0x5FFF
STR r1,[r8]
LDRSB r3,[r8],#3

12. What would be the content of the memory location 0x4016 (8 bit value) after execution of the
following program. Give clear reason for your answer. (Assuming default endianness of the
processor, which is being used in the Lab)
[2 marks]
LDR R0, =0x4016;
LDR R1, =0x12345678;
STR R1, [R0];

13. What will the following instruction do?


[1 mark]
MSR cpsr_c, r0;

14. What are the values of each register used in the program? Assume a big-endian system.
[2 marks]
LDR r0,=32
LDR r1,=290
LDR r3,=296
LDR r5,=0xAABBCCDD(3)
LDR r6,=0xEDABEABD
STR r6,[r1]
STR r5,[r3]
LDRSB r4,[r0],#0xF10,LSR #4

15. What will the following expressions do?


[2 marks]
I. coeff RN 0;
II. MOV R0, #0x09600000;
MVN R3, R0, ASR #4;

16. What are the values of each register used in the program?
[2 marks]
LDR r0,=0x12345678
EOR r1,r0,r0,ROR #13
BIC r1,r1,0xff000000
MOV r0,r0,ROR #8
EOR r0,r0,r1,LSR #8

17. Consider a 5 stage pipe-line, with stages; Fetch, decode, execute, Memory access and write-
back. Suppose we get a data abort exception. Can you tell in which stage it will be caught?
What should be the restored value of PC after servicing the exception handler?
[2 marks]

18. The code is given below to divide (117) 10 by (18) 10 and store the quotient and remainder at two
consecutive locations. Here is the program to do this task. Will it work correctly? If not, where
is/are the error(s). For each erroneous line, mention the line number and write the correct
instruction to replace it. (Errors can be of any type like logical errors, syntax errors etc.)
[4 marks]

LDR R0, =Lable2 ; line 1


LDR R1, =0x18 ; line 2
LDR R2, =0 ; line 3
LDR R5, =0x2000 ; line 4
Lable1 SUBS R0,R0,R1 ; line 5
ADDS R2,R2,#1 ; line 6
BPL Lable1 ; line 7
STR R2,[R5] ; line 8
ADD R0,R0,R1 ; line 9
STR R0,[R5,#4] ; line 10
Lable2 DCD 117 ; line 11

19. What is the maximum jump range for the branch instruction in ARM?
[1 mark]
20. Assuming a big-endian system, what would be the content of each register used in this program
after the execution of the following code snippet?
[2 marks]
MOV r0,oxFF
MOV r0,#0x1,30
MOV r0,#0x1,26
ADD r0,r2,#0xFF0F0FFF
SUB r2,r3,#0x8000
RSB r8,r9,#0x8000

21. In privileged mode, what does instruction “MOVS pc, lr” do?
[1 mark]

22. What is the output of the following instruction?


[1 mark]
MVN r0,#0xFF,8

23. What is wrong with the following instruction?


[1 mark]
STMIA r7!, {r7, r3, r10}

24. Fill in the table by the values of register/memory location after execution of the following
program. (Assume code is stored from 0x0 memory location in the memory)
[4 marks]
AREA prog1, CODE, READONLY
ENTRY
LDR R0,=Lable3
LDR R1,[R0]
LDR R3, =9
Lable1
CMP R3,#0
BEQ Lable2
LDR R2, [R0,#4]!
CMP R1, R2
SUB R3,R3,#1
BGE Lable1
LDR R4, Lable3
MOV R1,R2
B Lable1
Lable2
LDR R0, =0X2012
STR R1,[R0]

AREA data1, DATA, READONLY


Lable3 DCD 5, 1, 3, 9, 16, 1, 7, 11, 20, 2
END

Register name/ Memory location Value (Hexadecimal)

R0

R1

R2

R3

R4

R15

0x2012 (8 bits)

0x2013 (8 bits)

25. Write down the highest and the lowest priority interrupt.
[1 mark]
26. What would be the value of r0 after execution of the following instruction
[2 marks]
a. LDR R2, [R0]! , #4;
b. LDR R2, [R0, #4]! ;

27. Which flag would be used to check ‘=’ (equal to) condition? And what should be the value of
that flag for given condition to be satisfied?
[1 mark]

28. Can you load 0xF3CFFFFF to r0, without using ‘LDR’ instruction? Write the alternate instruction,
if available.
[1 mark]

29. r2 stores x, r3 stores y, r4 stores z.


write pseudo code in terms of x, y and z. (Assuming you are writing a program in c)
[2 marks]

CMP r2, #0
BLE L2
MOV r4, r2
MOV r4, r4, ASL #2
ADD r4, r4, r2
B stop
L2 MOV r4, r2, ASL #1
ADD r4, r4, r3
stop END
30. If the following instruction is executed, what impact will it make on carry and overflow flag?
(Assume r0 = 0x87654321 and r1 = 0x80001234 initially).
[1 mark]
ADDS r2, r0, r1.

You might also like