Given the following lists of signed integers:
List A: -50, 20, 6, 0, 6, -2, -4, 2, 10, 20
List B: 15, 25, 1, -1, 9, 1, 11, 9
Write an assembly program to do the followings:
- Allocate data memory to store the number lists.
(To initialize data, you may use the sample startup.s file below as an example.)
- Sort the number lists in ascending order using Bubble sort algorithm and store the result back to the original space.
- Create a new list, List C, by merging List A and List B keeping all entries in ascending order.
- Upload screenshot of lists A and B in data memory before the sort, after the sort, and the new list C.
- Assembly file (.s)
(You may use the provided pseudocode to implement your bubble sort. There are examples of register usage to hold temporary values. You may follow the example or you may use your own.)
Allocate space for number list
// Initialize number list
Write number entries to allocated space
// Sort loop
// R1: hold loop counter
// R2: address of entry n
// R3: address of entry n+1
Initialize loop counter in R1
Set address of entry 1 in R2
Set address of entry 2 in R3
Go to l_done if loop complete
Read entry n (address in R2)
Read entry n+1 (address in R3)
Compare both numbers
Go to l_next if n <= n+1
// Swap numbers
Swap positions n and n+1 in number list
go to l_begin
Increment addresses (in R2 and r3) to n+1 and n+2