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

SAMPLE QUESTIONS

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

0x08000136 multiply MUL r0, r1, r0


0x08000138 BX LR

i. If multiply is to be your SysTick interrupt subroutine, what should be the


interrupt vector’s value? Interrupt vector for SysTick is 0x0000.003C.

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

LDR R3, =0x25000000

STR R0, [R3]


STOP B STOP
Q3. Answer the following questions for TM4C123G microcontroller.
a. PORTB is connected to a two row by two column key pad (with key numbers 1,2,3,4)
and four LEDs. Keypad and LEDs are similar to the ones you used in the Lab
experiment 2. Draw a diagram to show the details of the keypad and LEDs and their
connections to the port pins and Vcc or ground if applicable.
b. Write down the initial values of the registers for this interfacing considering also that
when a key is pressed on the key pad, an interrupt should be initialized. Also state
the initial values for the output pins. Use labels for the registers and constants and
write their initialization values directly with the necessary explanation. For example:
RCGCGPIO = 0x02 ;enable clock for PORTB
c. Write the interrupt subroutine in THUMB2 assembly language where the value of the
pressed key (1,2,3 or 4) will be shown on the LEDs until the next key is pressed. Each
LED corresponds to a key. KEYVALUE is an available subroutine (you don’t need to
write it again) which returns the value of the pressed key in R12.
d. Write the main program in THUMB2 assembly language.
-
Q4.

a) Write a delay subroutine in THUMB2 assembly language for 500sec delay


without using timer. The system clock frequency is 16 MHz.

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.

You might also like