Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

x86-64 assembly: For each line below, add a short comment about what that line is for. Please ignore comments, .cfi* directives and the last two

x86-64 assembly: For each line below, add a short comment about what that line is for. Please ignore comments, .cfi* directives and the last two lines. The assembly code was obtained after compiling a simple program written in C (screenshot below). I think it will be convenient if you copy/paste the code in a text editor and then work.

.globl hello .data .type hello, @object .size hello, 6 hello: .string "hello" .globl world .section .rodata .LC0: .string "world" .data .align 8 .type world, @object .size world, 8 world: .quad .LC0 .comm arr_e,10,1 .local arr_s .comm arr_s,10,1 .text .globl foo .type foo, @function foo: .LFB0: .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 %rdi, -24(%rbp) # s, s movq %rsi, -32(%rbp) # d, d movq world(%rip), %rdx # world, world.0 movq -24(%rbp), %rax # s, s.1 addq %rdx, %rax # world.0, D.1753 movzbl (%rax), %eax # *_4, D.1754 leaq -16(%rbp), %rcx #, tmp70 movq -32(%rbp), %rdx # d, tmp72 addq %rcx, %rdx # tmp70, tmp71 movb %al, (%rdx) # D.1754, arr_a movq -24(%rbp), %rax # s, tmp74 addq $hello, %rax #, tmp73 movzbl (%rax), %eax # hello, D.1754 movq -32(%rbp), %rdx # d, tmp76 addq $arr_e, %rdx #, tmp75 movb %al, (%rdx) # D.1754, arr_e movq world(%rip), %rdx # world, world.2 movq -24(%rbp), %rax # s, s.3 addq %rdx, %rax # world.2, D.1753 movzbl (%rax), %eax # *_10, D.1754 movq -32(%rbp), %rdx # d, tmp78 addq $arr_s, %rdx #, tmp77 movb %al, (%rdx) # D.1754, arr_s movq -32(%rbp), %rdx # d, tmp79 movq -24(%rbp), %rax # s, tmp80 movq %rdx, %rsi # tmp79, movq %rax, %rdi # tmp80, call bar # movl $0, %eax #, D.1755 leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE0: .size foo, .-foo .globl main .type main, @function main: .LFB1: .cfi_startproc pushq %rbp # .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp #, .cfi_def_cfa_register 6 movl $2, %esi #, movl $1, %edi #, call foo # popq %rbp # .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE1: .size main, .-main .ident "GCC: (Ubuntu 4.8.2-19ubuntu1) 4.8.2" .section .note.GNU-stack,"",@progbits

The original program written in C:

image text in transcribed

The screenshot below is the code after compiling the C program in GCC. This is the same code provided above.

image text in transcribed

Thanks in advance.

1 char helloll"hello"; 2 char *world"world"; 3 char arr_e[10]; 4 static char arr s [101; 6 extern int bar(long s, long d); long d){ foo(long char arr_a [10]; 8 ? int s, 10 arr_ald]worldIsl; arr_e[d]-hello [s] arr-s [d] = world [5]; 12 13 14 15 16 174 18 19int main) 20 21A bar(s, d); return ; return foo(iL, 2L); 1 char helloll"hello"; 2 char *world"world"; 3 char arr_e[10]; 4 static char arr s [101; 6 extern int bar(long s, long d); long d){ foo(long char arr_a [10]; 8 ? int s, 10 arr_ald]worldIsl; arr_e[d]-hello [s] arr-s [d] = world [5]; 12 13 14 15 16 174 18 19int main) 20 21A bar(s, d); return ; return foo(iL, 2L)

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

Students also viewed these Databases questions