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

ECE 323 Lab Report

This lab report summarizes an ARM assembly lab that involved data transfer and sorting. The objective was to learn how to use LDR and STR instructions to store and retrieve data from memory. The task involved sorting an array of numbers in descending order and storing the sorted array in a different register. The code used various commands like LDR, STR, ADD, and CMP to load data, store data, perform calculations, and make comparisons to complete the sorting task. Bubble sorting was used, with nested loops to compare and swap elements until the array was fully sorted. The conclusion stated that the bubble sorting was successful after debugging the assembly code instructions.

Uploaded by

Nadeem Qandeel
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
128 views

ECE 323 Lab Report

This lab report summarizes an ARM assembly lab that involved data transfer and sorting. The objective was to learn how to use LDR and STR instructions to store and retrieve data from memory. The task involved sorting an array of numbers in descending order and storing the sorted array in a different register. The code used various commands like LDR, STR, ADD, and CMP to load data, store data, perform calculations, and make comparisons to complete the sorting task. Bubble sorting was used, with nested loops to compare and swap elements until the array was fully sorted. The conclusion stated that the bubble sorting was successful after debugging the assembly code instructions.

Uploaded by

Nadeem Qandeel
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

ECE 323 Lab Report Lab 02 ARM Assembly: Data Transfer and Sorting By Nadeem Qandeel 2/10/2014

1) Objective The goal is to learn how to use LDR and STR assembly instructions. Learn how data is stored in memory in addition to getting more practice in debugging ARM Assembly.

2) Components and Development tools used Hardware: No Hardware used in creating this project Development tools: Keil uvision4 with Assembly software.

3) Design and Implementation The task to be designed in this lab is to perform sortation to an array and storing in a different register in addition to also the computation of the average. Perform sorting to the array of number in descending order from maximum to minimum (high-low), after that storing the array in register R12 which is a pointer to the sorted array in R11. After calculating the average of the array storing in register R10. The code was written using different commands to complete the task. A list od registers RN were defined to take certain functions such as R12 for scrArrayAddr, R11 for destArrayAddr, R10 for average, lenAddr for R9 and the function SUM for R8. sizeOfitem was set to 1byte as size, location of memory for array was set to 0x400000000 using command LDR. The SUM was initialized to zero using LDR and the length of the array as well lenAddr=len2 the first element of the array and the memory address. Initialization in the code R0 was to zero by the MOV command, after initialization comparison between R0 and array length needed to be done using command CMP, and if the comparison with number 8 was equal then it branches to the loop used to perform average where ASR is used to divide by 8 and shift by 3 to give the average with keeping the sign and this loop is only done once and carries with

rest of the code and register R1 is set to zero. Otherwise the code doesnt branch at the BEQ command and skips to LDRSB following which loads a half word into register R9 that stores value then in R11 STRB R9[R11,R0] which as a result computes the total element in the array by doing summation sum=sum+R9 using the ADD command and doing the increment on register R0 by one and storing it in R0 and since it is a loop it goes back to the start of the loop and the same exact steps and incrementing until the comparison forces the pointer to get out of the loop and branch. The next loop is used to increment the value of register R2 and then doing comparison between R2 and R4 if so both registers are equal then it branches to looptwo otherwise the load sign byte R11 to R6 and R11 is incremented by one, R11 is loaded and updated to R7 by command LDRSB R7,[R11]. After comparison between R6 and R7 using the command BLE to go back to loop one if not the it executes the command STRB R6[R11],#-1 which stores value from R6 to the address of R11 and then R11=R11-1 and then stores value from R7 to the address R11 STRB R7,[R11],#1.

Whenever the code branches to the other loop two, countdown happens as r4 is equal to length of array len2 R1 using RSB R4,R1,#8 and moving 0 to the value of R2 and comparing finally the register R1 to the array length and if its true the code branches to done otherwise it increments until it gets there. array1 DCB 54, -119, 8, -39, 1, -93, 21, 127

becomes -119,-93,-39,1,8,21,54,127 after the bubble sorting.

4) Conclusion The bubble sorting was successful after the code written and was debugged the instruction and command performed the function of comparing swapping the smaller number taking into consideration the signed numbers and also going back to the and exiting the loop decrementing the number of comparisons as each time the highest number reaches the end. Storing the data in memory using the LDR and STR commands was helpful to achieve the objective. 5) Comments The lab required thinking ahead and identifying the main problem first and writes it down on a piece of paper before taking the steps to write the code.

6) Appendices

Sort numbers in ascending order

Do the sorting of numbers on a paper

Memory Address value

If its bigger move to the right SWAP

Compare sign numbers

If its smaller keep in place

Keep shifting and comparison

If number less than array length Stop shifting

Number of comparison decreases by one with every increment

End when all sorted

You might also like