This is what I have so far I need help with the commenting on the assembly code  I have included my C code that I commented and this assembly was generated from my C code so it can be of help   My assembly code largest(int*, int):         push    rbp         mov     rbp, rsp         mov     QWORD PTR [rbp-24], rdi         mov     DWORD PTR [rbp-28], esi         mov     rax, QWORD PTR [rbp-24]         mov     eax, DWORD PTR [rax]         mov     DWORD PTR [rbp-4], eax         mov     DWORD PTR [rbp-8], 1         jmp     .L2 .L4:         mov     eax, DWORD PTR [rbp-8]         cdqe         lea     rdx, [0+rax*4]         mov     rax, QWORD PTR [rbp-24]         add     rax, rdx         mov     eax, DWORD PTR [rax]         cmp     DWORD PTR [rbp-4], eax         jge     .L3         mov     eax, DWORD PTR [rbp-8]         cdqe         lea     rdx, [0+rax*4]         mov     rax, QWORD PTR [rbp-24]         add     rax, rdx         mov     eax, DWORD PTR [rax]         mov     DWORD PTR [rbp-4], eax .L3:         add     DWORD PTR [rbp-8], 1 .L2:         mov     eax, DWORD PTR [rbp-8]         cmp     eax, DWORD PTR [rbp-28]         jl      .L4         mov     eax, DWORD PTR [rbp-4]         pop     rbp         ret .LC0:         .string "enter the size of an array" .LC1:         .string "%d" .LC2:         .string "\n Enter the elements in an array:" .LC3:         .string "Largest number in array:%d" main:         push    rbp         mov     rbp, rsp         sub     rsp, 224         mov     edi, OFFSET FLAT:.LC0         mov     eax, 0         call    printf         lea     rax, [rbp-12]         mov     rsi, rax         mov     edi, OFFSET FLAT:.LC1         mov     eax, 0         call    __isoc99_scanf         mov     edi, OFFSET FLAT:.LC2         mov     eax, 0         call    printf         mov     DWORD PTR [rbp-4], 0         jmp     .L7 .L8:         lea     rdx, [rbp-224]         mov     eax, DWORD PTR [rbp-4]         cdqe         sal     rax, 2         add     rax, rdx         mov     rsi, rax         mov     edi, OFFSET FLAT:.LC1         mov     eax, 0         call    __isoc99_scanf         add     DWORD PTR [rbp-4], 1 .L7:         mov     eax, DWORD PTR [rbp-12]         cmp     DWORD PTR [rbp-4], eax         jl      .L8         mov     edx, DWORD PTR [rbp-12]         lea     rax, [rbp-224]         mov     esi, edx         mov     rdi, rax         call    largest(int*, int)         mov     DWORD PTR [rbp-8], eax         mov     eax, DWORD PTR [rbp-8]         mov     esi, eax         mov     edi, OFFSET FLAT:.LC3         mov     eax, 0         call    printf         mov     eax, 0         leave         ret My c code    #include   // C function to find maximum in arr[] of size n   int largest(int a[], int n)   {      // Initialize large element        int large=a[0];   // Traverse array elements from second and   // compare every element with current large    for(int i=1;i

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

This is what I have so far I need help with the commenting on the assembly code 



I have included my C code that I commented and this assembly was generated from my C code so it can be of help

 

My assembly code



largest(int*, int):

        push    rbp

        mov     rbp, rsp

        mov     QWORD PTR [rbp-24], rdi

        mov     DWORD PTR [rbp-28], esi

        mov     rax, QWORD PTR [rbp-24]

        mov     eax, DWORD PTR [rax]

        mov     DWORD PTR [rbp-4], eax

        mov     DWORD PTR [rbp-8], 1

        jmp     .L2

.L4:

        mov     eax, DWORD PTR [rbp-8]

        cdqe

        lea     rdx, [0+rax*4]

        mov     rax, QWORD PTR [rbp-24]

        add     rax, rdx

        mov     eax, DWORD PTR [rax]

        cmp     DWORD PTR [rbp-4], eax

        jge     .L3

        mov     eax, DWORD PTR [rbp-8]

        cdqe

        lea     rdx, [0+rax*4]

        mov     rax, QWORD PTR [rbp-24]

        add     rax, rdx

        mov     eax, DWORD PTR [rax]

        mov     DWORD PTR [rbp-4], eax

.L3:

        add     DWORD PTR [rbp-8], 1

.L2:

        mov     eax, DWORD PTR [rbp-8]

        cmp     eax, DWORD PTR [rbp-28]

        jl      .L4

        mov     eax, DWORD PTR [rbp-4]

        pop     rbp

        ret

.LC0:

        .string "enter the size of an array"

.LC1:

        .string "%d"

.LC2:

        .string "\n Enter the elements in an array:"

.LC3:

        .string "Largest number in array:%d"

main:

        push    rbp

        mov     rbp, rsp

        sub     rsp, 224

        mov     edi, OFFSET FLAT:.LC0

        mov     eax, 0

        call    printf

        lea     rax, [rbp-12]

        mov     rsi, rax

        mov     edi, OFFSET FLAT:.LC1

        mov     eax, 0

        call    __isoc99_scanf

        mov     edi, OFFSET FLAT:.LC2

        mov     eax, 0

        call    printf

        mov     DWORD PTR [rbp-4], 0

        jmp     .L7

.L8:

        lea     rdx, [rbp-224]

        mov     eax, DWORD PTR [rbp-4]

        cdqe

        sal     rax, 2

        add     rax, rdx

        mov     rsi, rax

        mov     edi, OFFSET FLAT:.LC1

        mov     eax, 0

        call    __isoc99_scanf

        add     DWORD PTR [rbp-4], 1

.L7:

        mov     eax, DWORD PTR [rbp-12]

        cmp     DWORD PTR [rbp-4], eax

        jl      .L8

        mov     edx, DWORD PTR [rbp-12]

        lea     rax, [rbp-224]

        mov     esi, edx

        mov     rdi, rax

        call    largest(int*, int)

        mov     DWORD PTR [rbp-8], eax

        mov     eax, DWORD PTR [rbp-8]

        mov     esi, eax

        mov     edi, OFFSET FLAT:.LC3

        mov     eax, 0

        call    printf

        mov     eax, 0

        leave

        ret




My c code 

 

#include <stdio.h>

 

// C function to find maximum in arr[] of size n

 

int largest(int a[], int n)

 

{

 

   // Initialize large element

 

     int large=a[0];

 

// Traverse array elements from second and

 

// compare every element with current large

 

 for(int i=1;i<n;i++)

 

    {

 

// If the current element is greater than large, then assign the value of large with the current element

 

        if(large<a[i])

 

        {

 

            large=a[i];

 

        }

 

    }

 

    return large;

 

    }

 

 

 

int main()

 

{

 

// declaration of variables   and array size

 

    int n;

 

    int largest_num;

 

    int a[50];

 

    printf("enter the size of an array");

 

    scanf("%d",&n);

 

    printf("\n Enter the elements in an array:");

 

    for(int i=0;i<n;i++)

 

    {

 

        scanf("%d",&a[i]);

 

    }

 

    largest_num=largest(a,n);

 

    printf("Largest number in array:%d",largest_num);

 

    return 0;

 

}

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Fundamentals of Computer System
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education