LABORATORY ON ARM MICROCONTROLLER PROGRAMMING & INTERFACING
SUBJECT CODE: MTES27 & MTMCT27
EXPERIMENT #4:
CONDITIONAL EXECUTION OF INSTRUCTION & LOOPS
To learn
(i) To learn about conditional branch instruction
(ii) To learn about condition execution of standard instructions to avoid
unnecessary branch instructions
(iii) To implement a simple command implementing routine similar to switch
case in C language
Procedure:
Part I: Familiarizing with conditional branching
1. Start uV5. Close all previous projects.
2. Open folder “4_Conditional_Execution_Loops”. Double click on file
“Loops_&_Others.uvprojx” to launch uV5 and open readymade project.
3. Add file “min_max_1.s” provided to you in this folder. Study the code.
4. This program defines three signed 32-bit numbers in ROM area as follows:
Number1 DCD 0x71111111
Number2 DCD 0xE034FE58
Number3 DCD 0x02AC89BD
5. Note that the second is a negative number since MSB is 1.
6. The minimum found will be stored in R4 and maximum in R5. These will also be stored in
designated RAM locations Minimum and Maximum.
7. It uses R0 as address pointer and gets 3 numbers from memory into registers R1, R2 and R3.
8. First half part calculates minimum of the three. Second half calculates maximum in the three
numbers.
9. We compare R1 and R2 by carrying out R-R2 operation internally without modifying R1 or R2.
Only flags are affected. If R1 < R2 then R4 = R1 else R4 = R2. In any case R4 contains
minimum of R1 and R2.
10.Next compare R4 with third number R3. If R4 is less then nothing needs to be done, else
copy R3 in R$.