This assignment is to help you understand the basics of IA-32 assembly language
ID: 3650302 • Letter: T
Question
This assignment is to help you understand the basics of IA-32 assembly language programming, including program structure, memory allocation in a data segment, addressing modes and instructions for data transfers, arithmetic operations and control flow. You will also learn how to use an IDE such as Visual Studio/C++ to edit and test assembly language programs.You are to, given the data below, design an IA-32 assembly language program to find the max and min of the array in X and save them in A and B respectively.
X sword 100,200,-100,-200,150,-150,300,250
A sword ?
B sword ?
Explanation / Answer
#include /* structure is used to return two values from minMax() */ struct pair { int min,int A,intB; int max; }; struct pair getMinMax(int arr[], int n) { struct pair minmax; int i; /* If array has even number of elements then initialize the first two elements as minimum and maximum */ if(n%2 == 0) { if(arr[0] > arr[1]) { minmax.max = arr[0]; minmax.min = arr[1]; } else { minmax.min = arr[0]; minmax.max = arr[1]; } i = 2; /* set the startung index for loop */ } /* If array has odd number of elements then initialize the first element as minimum and maximum */ else { minmax.min = arr[0]; minmax.max = arr[0]; i = 1; /* set the startung index for loop */ } /* In the while loop, pick elements in pair and compare the pair with max and min so far */ while(i arr[i+1]) { if(arr[i] > minmax.max) minmax.max = arr[i]; if(arr[i+1] minmax.max) minmax.max = arr[i+1]; if(arr[i]Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.