Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I need to match the C++ code with the corresponding assembly code. assembly code- .file assignment2_1.cpp .text .section .rodata .type _ZStL19piecewise_construct, @object .size _ZStL19piecewise_construct,

Hello, I need to match the C++ code with the corresponding assembly code.

assembly code-

.file "assignment2_1.cpp" .text .section .rodata .type _ZStL19piecewise_construct, @object .size _ZStL19piecewise_construct, 1 _ZStL19piecewise_construct: .zero 1 .local _ZStL8__ioinit .comm _ZStL8__ioinit,1,1 .LC0: .string "Enter a number: " .LC1: .string "The factorial for " .LC2: .string "is: " .text .globl main .type main, @function main: .LFB1493: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 subq $32, %rsp movq %fs:40, %rax movq %rax, -8(%rbp) xorl %eax, %eax movl $1, -12(%rbp) leaq .LC0(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdx movq _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rax movq %rax, %rsi movq %rdx, %rdi call _ZNSolsEPFRSoS_E@PLT leaq -20(%rbp), %rax movq %rax, %rsi leaq _ZSt3cin(%rip), %rdi call _ZNSirsERi@PLT movl -20(%rbp), %eax movl %eax, -16(%rbp) .L3: cmpl $0, -16(%rbp) jle .L2 movl -12(%rbp), %eax imull -16(%rbp), %eax movl %eax, -12(%rbp) subl $1, -16(%rbp) jmp .L3 .L2: leaq .LC1(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdx movl -20(%rbp), %eax movl %eax, %esi movq %rdx, %rdi call _ZNSolsEi@PLT leaq .LC2(%rip), %rsi movq %rax, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdx movl -12(%rbp), %eax movl %eax, %esi movq %rdx, %rdi call _ZNSolsEi@PLT movl $1, %eax movq -8(%rbp), %rcx xorq %fs:40, %rcx je .L5 call __stack_chk_fail@PLT .L5: leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE1493: .size main, .-main .type _Z41__static_initialization_and_destruction_0ii, @function _Z41__static_initialization_and_destruction_0ii: .LFB1982: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 subq $16, %rsp movl %edi, -4(%rbp) movl %esi, -8(%rbp) cmpl $1, -4(%rbp) jne .L8 cmpl $65535, -8(%rbp) jne .L8 leaq _ZStL8__ioinit(%rip), %rdi call _ZNSt8ios_base4InitC1Ev@PLT leaq __dso_handle(%rip), %rdx leaq _ZStL8__ioinit(%rip), %rsi movq _ZNSt8ios_base4InitD1Ev@GOTPCREL(%rip), %rax movq %rax, %rdi call __cxa_atexit@PLT .L8: nop leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE1982: .size _Z41__static_initialization_and_destruction_0ii, .-_Z41__static_initialization_and_destruction_0ii .type _GLOBAL__sub_I_main, @function _GLOBAL__sub_I_main: .LFB1983: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 movl $65535, %esi movl $1, %edi call _Z41__static_initialization_and_destruction_0ii popq %rbp .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE1983: .size _GLOBAL__sub_I_main, .-_GLOBAL__sub_I_main .section .init_array,"aw" .align 8 .quad _GLOBAL__sub_I_main .hidden __dso_handle .ident "GCC: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0" .section .note.GNU-stack,"",@progbits

image text in transcribedimage text in transcribed

1. Explain the functionality of the C++ code. Use the C++ to Assembly With Loops Activity Template to complete this step. The C++ file is located within the Software Reverse Engineering Playground in the Module Two file following table: #include using namespace std; int main() { int num, i; int product=1; cout>num; for(i=num;i>0; i--) product = product i; cout using namespace std; int main() { int num, i; int product=1; cout>num; for(i=num;i>0; i--) product = product * i; cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

Students also viewed these Databases questions

Question

We cant wait their decision much longer.

Answered: 1 week ago