Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

ARM Assembly and C Code for Microprocessor Operations and I/O Port Manipulation, Exams of Applied Economics

Arm assembly and c code examples for various microprocessor operations, including signed integer addition, multiplication loops, and memory loading. It also covers i/o port manipulation using the 8-bit i/o port at address 0x40005120. C keywords and optimization are discussed in relation to preventing unwanted code replacement.

Typology: Exams

2014/2015

Uploaded on 02/27/2015

kaansemyo
kaansemyo 🇹🇷

4 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ELM333 µ-processor Final 2013 student
name :
1. Write an ARM code to perform the following.
r4 =r0 +64r1
Assume that the integers are signed.
2. What does the following ARM code performs?
mov r4, #10
mov r5, #1
LOOP: mul r5, r5, r4
subs r4, r4, #1
bgt LOOP
3. What does the following ARM code performs?
mov r4, #0x2FC0 0000
mov r5, #7
mov r0, #1
LOOP: ldr r1, [r4, r5, LSL#2]
mul r0, r0, r1
subs r5, r5, #1
bge LOOP
4. What does the following ARM code performs?
mov r4, #0x2FC0 0000
mov r5, #7
mov r0, #0
LOOP: str r0, [r4, r5, LSL#2]
subs r5, r5, #1
bge LOOP
5. Write the C code equivalent of the ARM code.
cmp r4,#16
ble END
add r0, r0,#5
END:
if( ){
}
6. Let xbe a global variable stored at a direct
address and let ybe a local variable stored at
the address that is 8 byte higher than the stack
pointer. Which one of the codes below may load
xand which one may load y?
mov r4, 0x2F000000
ldr r1, [r4] ldr r0, [r13, #8]
7. Let the stack pointer r13=0xA0000000. Write
the ARM memory instructions loading the stack
variables x,y, and zto the registers r0,r1, and
r2 respectively.
0xA0000000
0xA0000004
0xA0000008
0xA000000C x
0xA0000010 y
0xA0000014 z
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
9. The below code sets first 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 key-
word must be used to prevent the optimization.
*(keyword char *)0x40005120 |= 1
*(keyword char *)0x40005120 |= 2
C keywords
auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while
1
pf2

Partial preview of the text

Download ARM Assembly and C Code for Microprocessor Operations and I/O Port Manipulation and more Exams Applied Economics in PDF only on Docsity!

ELM333 μ-processor Final 2013 studentname :

  1. Write an ARM code to perform the following.

r4 = r0 + 64r

Assume that the integers are signed.

  1. What does the following ARM code performs?

mov r4, # mov r5, # LOOP: mul r5, r5, r subs r4, r4, # bgt LOOP

  1. What does the following ARM code performs?

mov r4, #0x2FC0 0000 mov r5, # mov r0, # LOOP: ldr r1, [r4, r5, LSL#2] mul r0, r0, r subs r5, r5, # bge LOOP

  1. What does the following ARM code performs?

mov r4, #0x2FC0 0000 mov r5, # mov r0, # LOOP: str r0, [r4, r5, LSL#2] subs r5, r5, # bge LOOP

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

cmp r4,#

ble END

add r0, r0,#

END:

if( ){

}

  1. 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 r4, 0x2F ldr r1, [r4] ldr^ r0, [r13, #8]
  2. 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. 0xA 0xA 0xA 0xA000000C x 0xA0000010 y 0xA0000014 z
  3. 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. The below code sets first 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 key- word must be used to prevent the optimization. *(keyword char *)0x40005120 |= 1 *(keyword char *)0x40005120 |= 2 C keywords auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void default goto sizeof volatile do if static while
  1. If the clock source is 1MHz, how long will it take for the timer to count from 99 down to 0?
  2. Consider the graphics of the timer signals be- low. As seen, the maximum count in the period register is 99, the count register is loaded from the period register on the first positive transi- tion 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?

capture signal

clock

count value 99 98 97 96 95 94

  1. Let the clock source be 1MHz and the maximum count be 99. What value will the capture regis- ter have, if the capture signal goes high between 1.5 μsec and 2.5 μsec after the first positive tran- sition of the clock?
  2. Let the timer be configured such that the com- parison 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.
    1. Let the clock source of the timer be connected to some switch which gets connected to the ground when pressed. Which IO mode must be chosen for the μprocessor pin connected to the switch
    2. Tell the differences between a function call and interrupt service routine
    3. Draw a 4 bit DAC and explain
    4. Draw a SAR ADC and explain?
    5. Draw an SPI connection and explain