The task is to write an assembly program to search the data stored in the memory locations starting

The task is to write an assembly program to search the data stored in the memory locations starting from 0x20001000 to 0x2000101C (total 8 data) for the smallest number and store it to the memory location 0x20002000. An equivalent C program would look like,

 

//This C program is only to demonstrate the flow of the homework.

int32_t            i, temp=0, data[8];       //temp is equivalent to R0 register.

for (i=7; i>=0; i–)       {if (temp>data[i]) temp=data[i];}       //compare and keep the smaller one.

 

1.     Assume that the data are stored in the memory at the beginning. Do not assign any specific values to them.  The program should be general enough to work with any data in the memory in any order.

2.     Note that a memory address increments by 4, not by 1.

3.     Use the for-loop style iteration to scan all memory data in the range.

4.     Use R0 to store the smallest number.

5.     Use R1 to count the number of iteration.

 

Deliverables

vCreate a .s file in uVision and build the target. Debug your program until you get 0 error.

vWrite the class and section number, your name and Homework number at the very top in comments.

vThen submit your .s file to BBlearner. You can change your submission up to 5 times.

vDue time is the midnight of February 28 (Sun).

 

Hint

Use the post-offset indirect addressing to fetch data in the memory.

baseaddr                      equ      0x20001000

index_increment          equ      4

            . .

            ldr       r2, =baseaddr

            ldr       r4, [r2], #index_increment      ;fetch the data and increment r2 address

            cmp     r0, r4               ;compare r0 and r4

            blt        move_on          ;if r0 is less than r4, move on. If not, replace 

            mov     r0, r4

move_on

            sub       r1, r1, #1                     ;decrement the counter by one.

            . .

 

 

End

    • Posted: 4 years ago
    • Due: 21/02/2016
    • Budget: $5