You are to add these 3 functions to this program l readData

You are to add these 3 functions to this program l. readData This function is to read the input and store it into the array. Notice that there is one parameter (use Sa0 for this) and one return value (use Sv0 for this). You may access the array using subscripts or pointers through the parameters but you must not access the global data directly. Also, you must use $s registers for the variables count and i(below) As these are saved registers, you must save these registers on the stack at the beginning of the function and restore them at the end. This function does not call another function. You do not have to error check on the value of count. int read Data (int list tj) int count: cout How many values to read? cin count; for (int i 0; i count it cin list, til: //read in list tij return count; 2. print: This function is to print the contents of the array. Notice that there are two parameters (Sa0 for the array address and Sal for the count). You may access the array elements using subscripts or pointers through the parameters but you must not access the global data directly. Use a temporary register for the variable i. This function does not call another function. void print (int array t], int count) for (int i 0; i count i++) cout list tij 3. sort: The code below is for the bubble sort. This function must call the function swap correctly. Notice that there are two parameters (Sa0 for the array address and Sal for the count). You may use access the array elements using subscripts or pointers through the parameters but you must not access the global data directly. Use temporary registers for the variables i and j. void sort (int listij, int count) for (int i (count 1) i 0; i--) for (int j li j ii j++) if (list [j-l] list [j]) swap (list tj-11, list tj]) Specifics: Do not use any pseudo-instructions.

Solution

Here the code will be like

li $i0, 1
move $i1, $x1
addi $i2, $x1, 80
loop1:
sw $i0, ($i1)
addi $i1, $i1, 4
bne $i1, $i2, loop1

move $i1, $x1

loop2:
lw $i0, ($i1)
li $v0, 1
move $x0, $i0
syscall
addi $i1, $i1, 4
bne $i1, $i2, loop2

And Sorting function look like

Data Segment
Array1 db 28,22,27,24,23 # ts assume Arrayay is likeL
Data Ends

Begin:
mov ax, data
mov ds, ax
mov es, ax
mov bx, OFFSET Array1
mov cx, 5
mov dx, cx
Loop1:
mov si, 0
mov ax, si
inc ax
mov di, ax
mov dx, cx
Loop2:
mov al, [bx][si]
cmp al, [bx][di]
jg Loop4
Loop3:
inc si
inc di
dec dx
cmp dx, 00
je Loop1
jg Loop2
Loop4:
mov al, [bx][si]
mov ah, [bx][di]
mov [bx][si], ah
mov [bx][di], al
inc si
inc di   
dec dx
cmp dx, 00
je Loop1
jg Loop2
Exit:
mov ax, 4c00h
int 21h
Code Ends
End Begin

 You are to add these 3 functions to this program l. readData This function is to read the input and store it into the array. Notice that there is one parameter
 You are to add these 3 functions to this program l. readData This function is to read the input and store it into the array. Notice that there is one parameter

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site