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

Translate this c++ code into PEP/8 assembly language #include using namespace st

ID: 3568511 • Letter: T

Question

Translate this c++ code into PEP/8 assembly language

#include

using namespace std;

struct node{

node* next;

int data;

};

// Simple insert routine for linked lists

// in: call-by-reference to pointer

//      value to insert into the linked list

// out: insert at the top of the linked list

void insert(node*& ptr, int value) {

node* temp = new node;

temp->next = ptr;

temp->data = value;

ptr = temp;

}

int main() {

node* root = NULL;

node* p;

int value;

cin >> value;

while (value >= 0) {

    insert(root, value);

    cin >> value;

}

for (p = root; p != NULL; p=p->next)

    cout << p->data << ' ';

cout << endl;

return 0;

}

Explanation / Answer

.Ltext0: .globl _Z6insertRP4nodei _Z6insertRP4nodei: .LFB998: .cfi_startproc .LVL0: 0000 55 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 0001 53 pushq %rbx .cfi_def_cfa_offset 24 .cfi_offset 3, -24 0002 4883EC08 subq $8, %rsp .cfi_def_cfa_offset 32 0006 4889FB movq %rdi, %rbx 0009 89F5 movl %esi, %ebp .LBB11: 000b BF100000 movl $16, %edi 00 .LVL1: 0010 E8000000 call _Znwm 00 .LVL2: 0015 488B13 movq (%rbx), %rdx 0018 488910 movq %rdx, (%rax) 001b 896808 movl %ebp, 8(%rax) 001e 488903 movq %rax, (%rbx) .LBE11: 0021 4883C408 addq $8, %rsp .cfi_def_cfa_offset 24 0025 5B popq %rbx .cfi_def_cfa_offset 16 .LVL3: 0026 5D popq %rbp .cfi_def_cfa_offset 8 .LVL4: 0027 C3 ret .cfi_endproc .LFE998: .globl main main: .LFB999: .cfi_startproc 0028 53 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 0029 4883EC10 subq $16, %rsp .cfi_def_cfa_offset 32 .LBB12: 002d 48C74424 movq $0, 8(%rsp) 08000000 00 0036 488D7424 leaq 4(%rsp), %rsi 04 003b BF000000 movl $_ZSt3cin, %edi 00 0040 E8000000 call _ZNSirsERi 00 .LVL5: 0045 8B742404 movl 4(%rsp), %esi 0049 85F6 testl %esi, %esi 004b 7821 js .L4 .L5: 004d 488D7C24 leaq 8(%rsp), %rdi 08 0052 E8000000 call _Z6insertRP4nodei 00 .LVL6: 0057 488D7424 leaq 4(%rsp), %rsi 04 005c BF000000 movl $_ZSt3cin, %edi 00 0061 E8000000 call _ZNSirsERi 00 .LVL7: 0066 8B742404 movl 4(%rsp), %esi 006a 85F6 testl %esi, %esi 006c 79DF jns .L5 .L4: 006e 488B5C24 movq 8(%rsp), %rbx 08 .LVL8: 0073 4885DB testq %rbx, %rbx 0076 742C je .L6 .L7: 0078 8B7308 movl 8(%rbx), %esi 007b BF000000 movl $_ZSt4cout, %edi 00 0080 E8000000 call _ZNSolsEi 00 .LVL9: 0085 C6442403 movb $32, 3(%rsp) 20 .LVL10: .LBB13: .LBB14: 008a BA010000 movl $1, %edx 00 008f 488D7424 leaq 3(%rsp), %rsi 03 .LVL11: 0094 4889C7 movq %rax, %rdi 0097 E8000000 call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l 00 .LVL12: .LBE14: .LBE13: 009c 488B1B movq (%rbx), %rbx .LVL13: 009f 4885DB testq %rbx, %rbx 00a2 75D4 jne .L7 .LVL14: .L6: .LBB15: .LBB16: 00a4 BF000000 movl $_ZSt4cout, %edi 00 00a9 E8000000 call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_ 00 .LVL15: .LBE16: .LBE15: .LBE12: 00ae B8000000 movl $0, %eax 00 00b3 4883C410 addq $16, %rsp .cfi_def_cfa_offset 16 00b7 5B popq %rbx .cfi_def_cfa_offset 8 .LVL16: 00b8 C3 ret .cfi_endproc .LFE999: _GLOBAL__sub_I__Z6insertRP4nodei: .LFB1007: .cfi_startproc 00b9 4883EC08 subq $8, %rsp .cfi_def_cfa_offset 16 .LVL17: .LBB19: .LBB20: 00bd BF000000 movl $_ZStL8__ioinit, %edi 00 00c2 E8000000 call _ZNSt8ios_base4InitC1Ev 00 .LVL18: 00c7 BA000000 movl $__dso_handle, %edx 00 00cc BE000000 movl $_ZStL8__ioinit, %esi 00 00d1 BF000000 movl $_ZNSt8ios_base4InitD1Ev, %edi 00 00d6 E8000000 call __cxa_atexit 00 .LVL19: .LBE20: .LBE19: 00db 4883C408 addq $8, %rsp .cfi_def_cfa_offset 8 00df C3 ret .cfi_endproc .LFE1007: .section .init_array,"aw" .align 8 0000 00000000 .quad _GLOBAL__sub_I__Z6insertRP4nodei 00000000 .local _ZStL8__ioinit .comm _ZStL8__ioinit,1,1 .text .Letext0:

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