Professional Documents
Culture Documents
Sample Questions: Count - Zero Are in Registers R0, R1, R2, R3 Respectively
Sample Questions: Count - Zero Are in Registers R0, R1, R2, R3 Respectively
Q1.
a. Considering the initial values R0 = 0x0000.0001, R1 = 0x1000.0000, what will be the
values of N, Z, C, V flags of PSR after each of the following instructions is executed
independently.
N Z C V
RORS R0
SUBS R1, R1, RO
b. Assume a typical CPU has 16-bit address bus and 8 bit data bus. Only the address
spaces 0x2000 – 0x27FF and 0x2C00 – 0x33FF are available for RAMs. Design the
address decoding circuit using 3-to-8 decoder (with 2 active low, one active high
enable inputs and active low outputs) for four 1K RAM chips (with single active low
chip enable). Show all address bit connections to the RAM chips and the decoder.
c. Write the following code using Thumb2 assembly language and branching
instructions. Assume a, Count_positive, Count_negative,
Count_zero are in registers R0, R1, R2, R3 respectively.
If (a>0)
Count_positive = Count_positive + 1;
elseif (a<0)
Count_negative = Count_negative + 1;
else
Count_zero = Count_zero + 1;
d. Answer the following according to the code given below.
Address: maincode
0x08000124 MOV r1, #0x04
0x08000128 MOV r0, #0x02
0x0800012C ADDS r1,r1,r0
0x08000130 stop B stop
0x08000134
ii. If interrupt occurs while the main code instruction “MOV r0, #0x02” is
being executed, which registers with which values (if values are not
known leave them blank) are stored to the stack and what will be the new
values of LR and PC after the stacking?
Q2.
a) Draw a diagram or give an example demonstrating how descending-empty stack
works.
b) The following code should find the mean of N consecutive numbers (e.g., N1, .., N2).
To achieve this fill out the missing parts in the program and then trace the program.
Assume SP=0x2000.0000
N1 DCD 3
N2 DCD 6
SUMUP
ADD R0, R0, R1
SUBS R1, R1, #1
BGT SUMUP
MAIN
LDR R1, N2
LDR R2, N1
MOV R0, #0
b) Write a program in THUMB2 assembly language that turns off and on a LED. The
LED on/off duration can be changed using push-button switches. If switch A is
pressed, delay is doubled and when switch B is pressed delay is halved. Assume the
initial delay is 0xFFFF and the time between consecutive button presses is longer
than the delay time. The program stops if delay becomes less than 0xF. Use your
subroutine in part (b). Use labels for the registers and constants and write their
initialization values directly with the necessary explanation. Assume the
initialization for the GPIO is given as INITGPIO subroutine.