Assembly Language For this program you will call a procedure

Assembly Language:

For this program you will call a procedure that finds the minimum and maximum elements of an array, and the last positions in the array where the minimum and maximum element occurs.

The output of the program is:

The position in array of last occurrence of minimum element is: 4

The minimum element in the array is: 5

The position in array of last occurrence of maximum element is: 6

The maximum element in the array is: 90

Use an array named Array to contain the elements (as DWORDS):

5, 46, 90, 50, 5, 6, 90, 8, 20

All variables in main are DWORDS.

The name of the procedure is MinandMax, and its equivalent call in C++ would be:

MinandMax(int &max, int &maxposn, int &min, int &maxposn,int& Array, int Arrsze);

All arguments must be passed on the stack. You must use the C++ calling conventions for ordering of arguments on the stack. You must use the conventions for caller and callee saved registers on slide 26 of SS7 assuming that all registers EAX, EBX, ECX, EDX, EDI, ESI may be used for some purpose in main other than support for calling MinandMax.

Registers EAX, EBX, ECX, EDX, EDI, ESI are used for some purpose in MinandMax.

In MinandMax, there is only one loop. Thus, you must use conditionals within the loop to implement finding the maximum element, minimum element, position of the maximum element and position of the minimum element.

The ebp register must be saved within MinandMax.

The caller is responsible for cleaning up the stack.

The last line in the program should be END main

Solution

Answer:

.zero 1
.LC0:
.string \"\ \ \\t ENTER THE SIZE OF THE ARRAY\\342\\200\\246:\"
.LC1:
.string \"\ \ \\t ENTER THE ELEMENTS OF THE ARRAY\\342\\200\\246: \"
.LC2:
.string \"\ \ \\t THE LARGEST ELEMENT IS\\342\\200\\246: %d\"
.LC3:
.string \"\ \ \\t AND ITS POSSITION IS\\342\\200\\246: %d\"
.LC4:
.string \"\ \ \\tTHE SMALlEST ELEMENT IS\\342\\200\\246: %d\"
main:
push rbp
mov rbp, rsp
sub rsp, 144
mov esi, OFFSET FLAT:.LC0
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
lea rax, [rbp-132]
mov rsi, rax
mov edi, OFFSET FLAT:std::cin
call std::basic_istream<char, std::char_traits<char> >::operator>>(int&)
mov esi, OFFSET FLAT:.LC1
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
mov DWORD PTR [rbp-20], 1
.L3:
mov eax, DWORD PTR [rbp-132]
cmp DWORD PTR [rbp-20], eax
jg .L2
lea rax, [rbp-128]
mov edx, DWORD PTR [rbp-20]
movsx rdx, edx
sal rdx, 2
add rax, rdx
mov rsi, rax
mov edi, OFFSET FLAT:std::cin
call std::basic_istream<char, std::char_traits<char> >::operator>>(int&)
add DWORD PTR [rbp-20], 1
jmp .L3
.L2:
mov eax, DWORD PTR [rbp-124]
mov DWORD PTR [rbp-4], eax
mov DWORD PTR [rbp-12], 1
mov DWORD PTR [rbp-20], 1
.L6:
mov eax, DWORD PTR [rbp-132]
cmp DWORD PTR [rbp-20], eax
jg .L4
mov eax, DWORD PTR [rbp-20]
cdqe
mov eax, DWORD PTR [rbp-128+rax*4]
cmp eax, DWORD PTR [rbp-4]
jle .L5
mov eax, DWORD PTR [rbp-20]
cdqe
mov eax, DWORD PTR [rbp-128+rax*4]
mov DWORD PTR [rbp-4], eax
mov eax, DWORD PTR [rbp-20]
mov DWORD PTR [rbp-12], eax
.L5:
add DWORD PTR [rbp-20], 1
jmp .L6
.L4:
mov eax, DWORD PTR [rbp-124]
mov DWORD PTR [rbp-8], eax
mov DWORD PTR [rbp-16], 1
mov DWORD PTR [rbp-20], 1
.L9:
mov eax, DWORD PTR [rbp-132]
cmp DWORD PTR [rbp-20], eax
jg .L7
mov eax, DWORD PTR [rbp-20]
cdqe
mov eax, DWORD PTR [rbp-128+rax*4]
cmp eax, DWORD PTR [rbp-8]
jge .L8
mov eax, DWORD PTR [rbp-20]
cdqe
mov eax, DWORD PTR [rbp-128+rax*4]
mov DWORD PTR [rbp-8], eax
mov eax, DWORD PTR [rbp-20]
mov DWORD PTR [rbp-16], eax
.L8:
add DWORD PTR [rbp-20], 1
jmp .L9
.L7:
mov esi, OFFSET FLAT:.LC2
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
mov rdx, rax
mov eax, DWORD PTR [rbp-4]
mov esi, eax
mov rdi, rdx
call std::basic_ostream<char, std::char_traits<char> >::operator<<(int)
mov esi, OFFSET FLAT:.LC3
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
mov rdx, rax
mov eax, DWORD PTR [rbp-12]
mov esi, eax
mov rdi, rdx
call std::basic_ostream<char, std::char_traits<char> >::operator<<(int)
mov esi, OFFSET FLAT:.LC4
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
mov rdx, rax
mov eax, DWORD PTR [rbp-8]
mov esi, eax
mov rdi, rdx
call std::basic_ostream<char, std::char_traits<char> >::operator<<(int)
mov esi, OFFSET FLAT:.LC3
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
mov rdx, rax
mov eax, DWORD PTR [rbp-16]
mov esi, eax
mov rdi, rdx
call std::basic_ostream<char, std::char_traits<char> >::operator<<(int)
mov eax, 0
leave
ret
__static_initialization_and_destruction_0(int, int):
push rbp
mov rbp, rsp
sub rsp, 16
mov DWORD PTR [rbp-4], edi
mov DWORD PTR [rbp-8], esi
cmp DWORD PTR [rbp-4], 1
jne .L13
cmp DWORD PTR [rbp-8], 65535
jne .L13
mov edi, OFFSET FLAT:std::__ioinit
call std::ios_base::Init::Init()
mov edx, OFFSET FLAT:__dso_handle
mov esi, OFFSET FLAT:std::__ioinit
mov edi, OFFSET FLAT:std::ios_base::Init::~Init()
call __cxa_atexit
.L13:
nop
leave
ret
push rbp
mov rbp, rsp
mov esi, 65535
mov edi, 1
call __static_initialization_and_destruction_0(int, int)
pop rbp
ret

Assembly Language: For this program you will call a procedure that finds the minimum and maximum elements of an array, and the last positions in the array where
Assembly Language: For this program you will call a procedure that finds the minimum and maximum elements of an array, and the last positions in the array where
Assembly Language: For this program you will call a procedure that finds the minimum and maximum elements of an array, and the last positions in the array where
Assembly Language: For this program you will call a procedure that finds the minimum and maximum elements of an array, and the last positions in the array where

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site