Vous êtes sur la page 1sur 2

ELM333 -processor Final 2013 1. Write an ARM code to perform the following.

r4 = r0 + 64r1 Assume that the integers are signed.

student name

6. Let x be a global variable stored at a direct address and let y be a local variable stored at the address that is 8 byte higher than the stack pointer. Which one of the codes below may load x and which one may load y?
mov ldr r4, 0x2F000000 r1, [r4] ldr r0, [r13, #8]

2. What does the following ARM code performs? mov mov mul subs bgt r4, r5, r5, r4, #10 #1 r4 #1 LOOP

7. Let the stack pointer r13=0xA0000000. Write the ARM memory instructions loading the stack variables x, y, and z to the registers r0, r1, and r2 respectively. 0xA0000000 0xA0000004 0xA0000008 0xA000000C 0xA0000010 0xA0000014


r5, r4,

x y z

3. What does the following ARM code performs? mov mov mov ldr mul subs bge r4, r5, r0, r1, r0, r5, #0x2FC0 0000 #7 #1 r5, LSL#2] r1 #1 LOOP


[r4, r0, r5,

8. How do the following code change the pins of the 8 bit I/O port whose data register at the address 0x40005120? *(char *)0x40005120 &= 0x0F *(char *)0x40005120 |= 0x0F

4. What does the following ARM code performs? mov mov mov str subs bge r4, r5, r0, r0, r5, #0x2FC0 0000 #7 #0 r5, LSL#2] #1 LOOP

9. The below code sets rst I/O pin 0 and a few cycles later sets I/O pin 1. *(char *)0x40005120 |= 1 *(char *)0x40005120 |= 2 However, the optimization replaces this code with *(char *)0x40005120 |= 3. Which keyword must be used to prevent the optimization. *(keyword char *)0x40005120 |= 1 *(keyword char *)0x40005120 |= 2


[r4, r5,

5. Write the C code equivalent of the ARM code.

cmp r4,#16 ble END add r0, r0,#5 END: } if( ){

auto break case char const continue default do

C keywords double int else long enum register extern return float short for signed goto sizeof if static

struct switch typedef union unsigned void volatile while

10. If the clock source is 1MHz, how long will it take 14. Let the clock source of the timer be connected to for the timer to count from 99 down to 0? some switch which gets connected to the ground when pressed. Which IO mode must be chosen for the processor pin connected to the switch

11. Consider the graphics of the timer signals be- 15. Tell the dierences between a function call and interrupt service routine low. As seen, the maximum count in the period register is 99, the count register is loaded from the period register on the rst positive transition of the clock, and the capture signal is high on the fourth positive transition of the clock. What will be the value of the capture register?
count value 99 98 97 96 95 94

16. Draw a 4 bit DAC and explain


capture signal

17. Draw a SAR ADC and explain? 12. Let the clock source be 1MHz and the maximum count be 99. What value will the capture register have, if the capture signal goes high between 1.5 sec and 2.5 sec after the rst positive transition of the clock?

18. Draw an SPI connection and explain

13. Let the timer be congured such that the comparison output is high when the count value is less than the compare register. What must be value in the compare register to generate pulses with 50% duty cycle.