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

CSE2016 – Microprocessor and Microcontrollers

LAB FAT
Professor: Dr. Naresh K Slot: L15 + L16
1. Name: Bhimaraju Hari Prashant
2. Registration Number: 19BCT0154
Team Members:
3. Bhimaraju Hari Prashant – 19BCT0154
4. Lakshmi Tarun Kodali – 19BCT0113
5. Narapureddy Ram Rohith – 19BCT0131
IDE: Keil µVision IDE

a) First identify the name of the program shown in Fig.1


→ Number of odd elements in an array.

b) Next draft the step by step process (algorithm) in the document.


→ Step 1: Start.
Step 2: Write the Area Directive for Data Path.
Step 3: In Data Path, under Assembler Directive DCD, read the 10 elements of
the array in Hexadecimal format.
Step 4: Write the Area Directive for Code Path.
Step 5: Load constant value into registers R0 with 1, R3 with 0.
Step 6: Load base address of the 1st element of the array into register R1.
Step 7: Store the count of no. of elements in the array into register R2.
Step 8: Load the constant value whose address is stored in R1 register to R5
register
Step 9: Perform TST (ANDS without result) operation between R0 and R5
register. The zero flag will be set if the result is 0.
Step 10: Now, we perform ADDNE. If the zero flag is not set, we will add 1 to
the R3 counter register.
Step 11: Decrement the value of R2 register by 1.
Step 12: Increment value of R1 register by 4 so that it points to the next array
element.
Step 13: Repeat steps until value of R2 register becomes zero.
Step 14: Stop. We can see the number of odd elements in the array in R3
register.

c) Run the ARM based Program shown Fig.1 in keilµ4 version


→ Code:
AREA BELL, CODE, READONLY
ENTRY

MOV R0,#01
MOV R3,#00
LDR R1,=array
MOV R2,#0x09
lbl LDR R5,[R1]
TST R0,R5
ADDNE R3,R3,#01
SUBS R2,R2,#01
ADD R1,R1,#4
BPL lbl
l Bl
array DCD 0X11223343, 0X12345672, 0X002917BD3, 0X00000A01,
0X62398746, 0XAB56E3CE, 0X0A761AC7, 0X623ABC46, 0XAB86E3BD,
0X0A762DE9
END
Further in depth explanation has been provided in the video link attached
at the bottom of the file.

d) What will be the name of the program in case the instruction 11 in the
Fig.1 is replaced with ADDEQ R3,R3,#01
→ Number of even elements in the array.

e) In case the last input in the Fig.1 is changed from 0x0A762DE8 to


0X0A762DE9, then what change occurs in the output?
→ Currently we have five odd and five even elements in the array. If we
change the last input in the array from 0x0A762DE8 to 0X0A762DE9, now the
odd elements in the array become six. So we can run the program and see
the change in R3 register which indicates the number of odd elements in the
array (R3 becomes 6).

Video Link: https://youtu.be/22zx5U0dcno

You might also like