0% found this document useful (0 votes)
15 views

Tutorial 3

The document provides exercises on ARM assembly programming. It includes examples of loops, comparisons, subroutines, swapping memory contents, and conditional instructions. Solutions to the exercises are not given.

Uploaded by

Sami Keyrouz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Tutorial 3

The document provides exercises on ARM assembly programming. It includes examples of loops, comparisons, subroutines, swapping memory contents, and conditional instructions. Solutions to the exercises are not given.

Uploaded by

Sami Keyrouz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

EEET2096

Embedded System Design and


Implementation

Jidong Wang
MicroVision Help Manual
ARM and Thumb Instruction Summary
Cortex-M4 Programming Manual ( PM0214)
Assembly Programming Exercise

Exercise 1: Give a structure of a


loop which loops 12 times.
mov r0, #12
Myloop …


subs r0, r0, 1
bne Myloop
Assembly Programming Exercise

Exercise 2: Give the code to do the following: Compare r1 and r2. If r1 is


greater or equal ( as signed numbers) than r2, then r0 will get the value
of r1. If not r0 will keep its orginal value.

cmp r1, r2
blt skip
mov r0, r1
skip …


Assembly Programming Exercise

Exercise 3: Give the code of a subroutine: The name of the subroutine is


called Add_array. This subroutine will add up all the elements in a 8 bits
unsigned array. The total is kept in r0. The beginning of the array, ie the
address of the first element in the array is kept in r1. The length of the
array is kept in r2.
Add_array PROC
mov r0 , #0
myloop ldrb r3, [r1]
add r0,r0, r3
add r1, r1, 1
subs r2, r2, 1
bne myloop
bx lr
Question 4
Assume registers r1, r2 are two pointers to
memory. Write a short code to swap the
contents of the memory at [r1] and [r2].
Assume that the memory is byte wide.
Exercise 5
Assume r3 and r4 hold the values of 0x00000099
and 0x00000078.
MOV R0, #0
CMPB R3, r4
BHI skip
MOV R0, #7
BL next
Skip CMPB R3, R4
BGT skip2
MOV R0, #8
BL Next
Skip2 MOV R0, #9
Next MOV R1, #0x10

What will be the value of R0 before the instruction


at Next is executed?
Explanation on the tasks
Hint on theAbout
algorithm(s)
Lab 2

You might also like