Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help in assmebly language programming. please give output screenshots if po

ID: 3593829 • Letter: N

Question

Need help in assmebly language programming. please give output screenshots if possible

Asse mblyanquoex S Implement tnr itlouing c4t assembq lanquage se the block sucuedIF ond directives Assume WIHILE thot au variables are 32-bit intrgers int arraI3, ,5, 9, 2,6,5, 3 nt lower 3 nt upper int index 0 while (index Arroyze) SumEO Carray Ciodex 13 louer 98 a rray tindexlkupe) sum += ndex tt array L index] Your assembly languoge program must altso dispky os outpud the number o thtes a member o am uali he varnble sum' was. (Hird you moy houe to odd ardthe

Explanation / Answer

#include <iostream>

using namespace std;

int main() {

    int array[] = {3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4};

    int lower = 3;

    int upper = 8;

    int Arraysize = sizeof array/sizeof lower;

    int index = 0;

    int sum = 0;

    int counter = 0;

    while(index < Arraysize) {

        if(array[index] >= lower && array[index] <= upper){

            sum += array[index];

            index++;

            counter++;

        }

    }

    cout<<"Number of times array qualified "<<counter;

    cout<<"Sum of array: "<<sum;

    return 0;

}

------------------------------------------------------------------------------------------------------------------------------------------------------

x86 assenbly

.LC0:

.string "Number of times array qualified "

.LC1:

.string "Sum of array: "

main:

push rbp

mov rbp, rsp

sub rsp, 112

mov DWORD PTR [rbp-112], 3

mov DWORD PTR [rbp-108], 1

mov DWORD PTR [rbp-104], 4

mov DWORD PTR [rbp-100], 1

mov DWORD PTR [rbp-96], 5

mov DWORD PTR [rbp-92], 9

mov DWORD PTR [rbp-88], 2

mov DWORD PTR [rbp-84], 6

mov DWORD PTR [rbp-80], 5

mov DWORD PTR [rbp-76], 3

mov DWORD PTR [rbp-72], 5

mov DWORD PTR [rbp-68], 8

mov DWORD PTR [rbp-64], 9

mov DWORD PTR [rbp-60], 7

mov DWORD PTR [rbp-56], 9

mov DWORD PTR [rbp-52], 3

mov DWORD PTR [rbp-48], 2

mov DWORD PTR [rbp-44], 3

mov DWORD PTR [rbp-40], 8

mov DWORD PTR [rbp-36], 4

mov DWORD PTR [rbp-16], 3

mov DWORD PTR [rbp-20], 8

mov DWORD PTR [rbp-24], 20

mov DWORD PTR [rbp-4], 0

mov DWORD PTR [rbp-8], 0

mov DWORD PTR [rbp-12], 0

.L4:

mov eax, DWORD PTR [rbp-4]

cmp eax, DWORD PTR [rbp-24]

jge .L2

mov eax, DWORD PTR [rbp-4]

cdqe

mov eax, DWORD PTR [rbp-112+rax*4]

cmp DWORD PTR [rbp-16], eax

jg .L4

mov eax, DWORD PTR [rbp-4]

cdqe

mov eax, DWORD PTR [rbp-112+rax*4]

cmp DWORD PTR [rbp-20], eax

jl .L4

mov eax, DWORD PTR [rbp-4]

cdqe

mov eax, DWORD PTR [rbp-112+rax*4]

add DWORD PTR [rbp-8], eax

add DWORD PTR [rbp-4], 1

add DWORD PTR [rbp-12], 1

jmp .L4

.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*)

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:.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 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: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

.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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote