Assembly Language Programming In this assignment, you will iteratively populate
ID: 3837521 • Letter: A
Question
Assembly Language Programming In this assignment, you will iteratively populate a fixed-size integer array of 10 elements, array_a, with integer values provided by scanf. The user will enter 10 positive integer values, one per line, and the program will store the 10 values in array_a[0], array_a[1], …, array_a[9]. Once the 10 integers are entered, your program will print the array, then prompt the user for a search value which may or may not exist in the array. If the value exists, your program must print all locations where the value is stored. If the value does not exist in the array, it will display the message “that value does not exist in the array!”. After all output has been displayed, the program should exit (do not prompt for additional input).
Explanation / Answer
.LC0:
.string "enter value in array"
.LC1:
.string "value of array"
.LC2:
.string " "
.LC3:
.string "value to be searched"
.LC4:
.string "num found at pos"
.LC5:
.string "item not found"
main:
push rbp
mov rbp, rsp
sub rsp, 80
mov DWORD PTR [rbp-24], 0
mov DWORD PTR [rbp-4], 0
mov DWORD PTR [rbp-12], 0
.L3:
cmp DWORD PTR [rbp-12], 9
jg .L2
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-64]
mov edx, DWORD PTR [rbp-12]
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-12], 1
jmp .L3
.L2:
mov DWORD PTR [rbp-16], 0
.L5:
cmp DWORD PTR [rbp-16], 9
jg .L4
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 esi, OFFSET FLAT:.LC2
mov rdi, rax
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 eax, DWORD PTR [rbp-16]
cdqe
mov eax, DWORD PTR [rbp-64+rax*4]
mov esi, eax
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream<char, std::char_traits<char> >::operator<<(int)
add DWORD PTR [rbp-16], 1
jmp .L5
.L4:
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*)
lea rax, [rbp-68]
mov rsi, rax
mov edi, OFFSET FLAT:std::cin
call std::basic_istream<char, std::char_traits<char> >::operator>>(int&)
mov DWORD PTR [rbp-20], 0
.L8:
cmp DWORD PTR [rbp-20], 9
jg .L6
mov eax, DWORD PTR [rbp-20]
cdqe
mov edx, DWORD PTR [rbp-64+rax*4]
mov eax, DWORD PTR [rbp-68]
cmp edx, eax
jne .L7
mov DWORD PTR [rbp-4], 1
mov eax, DWORD PTR [rbp-20]
add eax, 1
mov DWORD PTR [rbp-8], eax
jmp .L6
.L7:
add DWORD PTR [rbp-20], 1
jmp .L8
.L6:
cmp DWORD PTR [rbp-4], 1
jne .L9
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)
jmp .L10
.L9:
mov esi, OFFSET FLAT:.LC5
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*)
.L10:
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 .L14
cmp DWORD PTR [rbp-8], 65535
jne .L14
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
.L14:
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.