Starting from:

$30

ECE253-Lab 8 Solved

1.    learn how to write basic programs in assembly language

2.    learn how to use loops and subroutines in assembly language

2   Part I
In Lab 7, you were given sample code in Part 2 to review and understand. Now you will be modifying that code to use subroutines.

Specifically, perform the following:

1.    Make a copy of the file part2.s from Lab 7 and call it part1.s.

2.   Take the code which calculates the number of consecutive 1s and make it into a subroutine called ONES. Have the subroutine use register R1 to receive the input data and register R0 for returning the result. At the top of your file, make the subroutine global .global ONES. This will allow the automarker to call your subroutine from another file.

3.    Add more words in memory starting from the label TESTNUM. You can add as manywords as you like—but include at least 10 words. Terminate the list with a -1.

4.    In your main program (in a separate file), call the newly-created subroutine in a loopfor every word of data that you placed in memory. Keep track of the longest string of 1s in any of the words, and have this result in register R5 when your program completes execution. Note: The cpulator simulator requires all your code to

be in one file. For testing and debugging with the simulator, please put all your code in one file and then copy paste the subroutine to a separate file for submission. You can have multiple files when running on the DE1-SoC boards in lab.

5.    Make sure to use the single-step capability of the simulator to step through yourcode and observe what happens when your subroutine call and return instructions are executed.

3   Part II
Write an assembly language program to sort a list of 32-bit unsigned numbers into ascending order. The first 32-bit number in the list gives the number of items in the list and the remainder of the entries are the numbers to be sorted. The list of data must be sorted “in place”, meaning that you are not allowed to create a copy in memory of the list to do the sorting. The list you should sort, including the number count, can be defined using the .word directive at the end of your program as follows:

LIST: .word 10, 1400, 45, 23, 5, 3, 8, 17, 4, 20, 33

More products