Please provide x86 ( MASM not NASM ) Assembly code for the following (needs to b
ID: 3912299 • Letter: P
Question
Please provide x86 (MASM not NASM) Assembly code for the following (needs to be compatible with Visual Studio 2015.asm file):
(10 points) Write an assembly program to find the largest element by searching an array int aryll-[11, 15,-3,-4, 0,60.11,-9,18) int index-l; int max- 0; int arraySize-sizeof array /sizeof max while (index max) max = ary[index]; - Use cmp instruction and the appropriate jump instruction (signed or unsigned) to translate the if and while statements Use S operator (see chapter 3) to calculate the size of the array, and inc instruction to increment the index of the array Run your program using the debugger to verify your answers (do this too for questions 2) Maximum value should be in max variable at the end. -Submit the following: o Lastname1.asmExplanation / Answer
.LC0:
.string "max value"
main:
push rbp
mov rbp, rsp
sub rsp, 48
mov DWORD PTR [rbp-48], 11
mov DWORD PTR [rbp-44], 15
mov DWORD PTR [rbp-40], -3
mov DWORD PTR [rbp-36], -4
mov DWORD PTR [rbp-32], 0
mov DWORD PTR [rbp-28], 60
mov DWORD PTR [rbp-24], 11
mov DWORD PTR [rbp-20], -9
mov DWORD PTR [rbp-16], 18
mov DWORD PTR [rbp-4], 1
mov DWORD PTR [rbp-8], 0
mov DWORD PTR [rbp-12], 9
.L4:
mov eax, DWORD PTR [rbp-4]
cmp eax, DWORD PTR [rbp-12]
jge .L2
mov eax, DWORD PTR [rbp-4]
cdqe
mov eax, DWORD PTR [rbp-48+rax*4]
cmp DWORD PTR [rbp-8], eax
jge .L3
mov eax, DWORD PTR [rbp-4]
cdqe
mov eax, DWORD PTR [rbp-48+rax*4]
mov DWORD PTR [rbp-8], eax
.L3:
add DWORD PTR [rbp-4], 1
jmp .L4
.L2:
mov esi, OFFSET FLAT:.LC0
mov edi, OFFSET FLAT:_ZSt4cout
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 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 .L8
cmp DWORD PTR [rbp-8], 65535
jne .L8
mov edi, OFFSET FLAT:_ZStL8__ioinit
call std::ios_base::Init::Init() [complete object constructor]
mov edx, OFFSET FLAT:__dso_handle
mov esi, OFFSET FLAT:_ZStL8__ioinit
mov edi, OFFSET FLAT:_ZNSt8ios_base4InitD1Ev
call __cxa_atexit
.L8:
nop
leave
ret
_GLOBAL__sub_I_main:
push rbp
mov rbp, rsp
mov esi, 65535
mov edi, 1
call __static_initialization_and_destruction_0(int, int)
pop rbp
ret
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.