Translate this C++ program to assembly language and upload your .pep file here.
ID: 3556512 • Letter: T
Question
Translate this C++ program to assembly language and upload your .pep file here. The change from the original is noted. The .cpp source file is included if you want to download and run it. Be sure to include comments!
#include <iostream>
using namespace std;
int overtake(int a, int b){ // Moved the do..while loop into a typed function
do{ // with pass by value parameters.
a += 25;
b += 20;
}
while (a < b);
return a;
}
int main() {
int cop = 0;
int driver = 40;
cout << overtake(cop, driver);
return 0;
}
pep file please!
Explanation / Answer
.Ltext0: .local _ZStL8__ioinit .comm _ZStL8__ioinit,1,1 .globl _Z8overtakeii _Z8overtakeii: .LFB971: .cfi_startproc 0000 55 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 0001 4889E5 movq %rsp, %rbp .cfi_def_cfa_register 6 0004 897DFC movl %edi, -4(%rbp) 0007 8975F8 movl %esi, -8(%rbp) .L2: 0012 8B45FC movl -4(%rbp), %eax 0015 3B45F8 cmpl -8(%rbp), %eax 0018 7CF0 jl .L2 000a 8345FC19 addl $25, -4(%rbp) 000e 8345F814 addl $20, -8(%rbp) 001a 8B45FC movl -4(%rbp), %eax 001d 5D popq %rbp .cfi_def_cfa 7, 8 001e C3 ret .cfi_endproc .LFE971: .globl main main: .LFB972: .cfi_startproc 001f 55 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 0020 4889E5 movq %rsp, %rbp .cfi_def_cfa_register 6 0023 4883EC10 subq $16, %rsp .LBB2: 0027 C745F800 movl $0, -8(%rbp) 000000 002e C745FC28 movl $40, -4(%rbp) 000000 0035 8B55FC movl -4(%rbp), %edx 0038 8B45F8 movl -8(%rbp), %eax 003b 89D6 movl %edx, %esi 003d 89C7 movl %eax, %edi 003f E8000000 call _Z8overtakeii 00 0044 89C6 movl %eax, %esi 0046 BF000000 movl $_ZSt4cout, %edi 00 004b E8000000 call _ZNSolsEi 00 0050 B8000000 movl $0, %eax 00 .LBE2: 0055 C9 leave .cfi_def_cfa 7, 8 0056 C3 ret .cfi_endproc .LFE972: _Z41__static_initialization_and_destruction_0ii: .LFB973: 0074 BF000000 movl $_ZStL8__ioinit, %edi 00 0079 E8000000 call _ZNSt8ios_base4InitC1Ev 00 007e BA000000 movl $__dso_handle, %edx 00 0083 BE000000 movl $_ZStL8__ioinit, %esi 00 0088 BF000000 movl $_ZNSt8ios_base4InitD1Ev, %edi 00 008d E8000000 call __cxa_atexit 00 .cfi_startproc 0057 55 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 0058 4889E5 movq %rsp, %rbp .cfi_def_cfa_register 6 005b 4883EC10 subq $16, %rsp 005f 897DFC movl %edi, -4(%rbp) 0062 8975F8 movl %esi, -8(%rbp) 0065 837DFC01 cmpl $1, -4(%rbp) 0069 7527 jne .L6 006b 817DF8FF cmpl $65535, -8(%rbp) FF0000 0072 751E jne .L6 .L6: 0092 C9 leave .cfi_def_cfa 7, 8 0093 C3 ret .cfi_endproc .LFE973: _GLOBAL__sub_I__Z8overtakeii: .LFB974: .cfi_startproc 0094 55 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 0095 4889E5 movq %rsp, %rbp .cfi_def_cfa_register 6 0098 BEFFFF00 movl $65535, %esi 00 009d BF010000 movl $1, %edi 00 00a2 E8B0FFFF call _Z41__static_initialization_and_destruction_0ii FF 00a7 5D popq %rbp .cfi_def_cfa 7, 8 00a8 C3 ret .cfi_endproc .LFE974: .section .init_array,"aw" .align 8 0000 00000000 .quad _GLOBAL__sub_I__Z8overtakeii 00000000 .text .Letext0:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.