ASSEMBLY language need homework help. DUE TODAY! Write a proc that prints arrray
ID: 3607131 • Letter: A
Question
ASSEMBLY language need homework help. DUE TODAY!
Write a proc that prints arrray.
Print starting array.
Print the array after each pass through.
Print the final array sorted.
so far what I have:
bubbleArray BYTE 5, 1, 4, 2, 8
.code
main PROC
mov ecx, lengthOf bubbleArray ; load ECS with # of elements of array
dec ecx ; decrement count by 1
L1: push ecx ; save outer loop count
mov esi, OFFSET bubbleArray ; point to first value
L2: mov eax,[esi] ; get array value
cmp [esi+1], eax ; compare a pair of values
jge L3 ; if [esi] <= [edi], don't exch
xchg eax, [esi+1] ; exchange the pair
mov [esi], eax
L3: inc esi ; increment esi to the next value
loop L2 ; inner loop
pop ecx ; retrieve outer loop count
loop L1 ; else repeat outer loop
L4: ret
main ENDP
printBubble PROC uses ecx esi
????not sure what to do here????
end MAIN
Explanation / Answer
#include<stdio.h>
/* Function to reverse arr[] from start to end*/
void rvereseArray(int arr[], int start, int end)
{
int temp;
while (start < end)
{
temp = arr[start];
arr[start] = arr[end];
arr[end] = temp;
start++;
end--;
}
}
/* Utility that prints out an array on a line */
void printArray(int arr[], int size)
{
int i;
for (i=0; i < size; i++)
printf("%d ", arr[i]);
printf("n");
}
/* Driver function to test above functions */
int main()
{
int arr[] = {1, 2, 3, 4, 5, 6};
printArray(arr, 6);
rvereseArray(arr, 0, 5);
printf("Reversed array is n");
printArray(arr, 6);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.