CS 410 assignment 1 C++ to Assembly Activity

.docx

School

Southern New Hampshire University *

*We aren’t endorsed by this school

Course

410

Subject

Computer Science

Date

Jan 9, 2024

Type

docx

Pages

3

Uploaded by BailiffSpider1312

Report
CS 410 C++ to Assembly Activity Template Step 1: Explain the functionality of the C++ code. This code calculate the area by multiplying the width and height and then displays the calculated area. C++ Code Functionality C++ Line of Code Explanation of Functionality #include<iostream> Includes the header file iostream using namespace std; Uses the standard namespace int main() Creates a function that returns an integer int width=10; Declares the width variable int height=5; Declares the height variable int area; Declares the area variable and assigns area to an integer area = width * height; Uses the mathematical equation to find the area cout<<endl<< area; Prints out the calculated area return 0; Returns functions value and exits the program Step 2: Convert the C++ file into assembly code. Step 3: Align each line of C++ code with the corresponding blocks of assembly code. C++ to Assembly Alignment C++ Line of Code Blocks of Assembly Code using namespace std; ZStL19piecewise_construct: .zero 1 .local _ZStL8__ioinit .comm _ZStL8__ioinit,1,1 .text .globl main .type main, @function int main() main: .LFB1493: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 subq $16, %rsp int width=10; movl $10, -12(%rbp)
int height=5; movl $5, -8(%rbp) int area; movl -12(%rbp), %eax area = width * height; imull -8(%rbp), %eax movl %eax, -4(%rbp) cout<<endl<< area; movl -4(%rbp), %eax movl %eax, %esi movq %rdx, %rdi call _ZNSolsEi@PLT return 0; movl $0, %eax leave .cfi_def_cfa 7, 8 ret .cfi_endproc
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help