​Can someone please help: (1) explain the functionality of these assembly codes (2) convert them to c++ (3) explain how the c++ code performs the same tasks as the blocks of assembly codes? I'm new to this and am struggling.

Anonymous
timer Asked: Jan 31st, 2021

Question Description

I'm working on a assembly language multi-part question and need guidance to help me understand better.

I'm new to this and am struggling. Therefore, any help is appreciated with these 4 files. Thanks!

gdb assignment4_1.o

(gdb) info functions

All defined functions:

Non-debugging symbols:

0x0000000000000000 main

0x00000000000000aa __static_initialization_and_destruction_0(int, int)

0x00000000000000f3 _GLOBAL__sub_I_main

(gdb) disassemble main

Dump of assembler code for function main:

0x0000000000000000 <+0>: push %rbp

0x0000000000000001 <+1>: mov %rsp,%rbp

0x0000000000000004 <+4>: sub $0x10,%rsp

0x0000000000000008 <+8>: movl $0x1,-0x8(%rbp)

0x000000000000000f <+15>: cmpl $0x9,-0x8(%rbp)

0x0000000000000013 <+19>: jg 0xa3 <main+163>

0x0000000000000019 <+25>: movl $0x1,-0xc(%rbp)

0x0000000000000020 <+32>: cmpl $0x9,-0xc(%rbp)

0x0000000000000024 <+36>: jg 0x9a <main+154>

0x0000000000000026 <+38>: mov -0x8(%rbp),%eax

0x0000000000000029 <+41>: imul -0xc(%rbp),%eax

0x000000000000002d <+45>: mov %eax,-0x4(%rbp)

0x0000000000000030 <+48>: mov -0x8(%rbp),%eax

0x0000000000000033 <+51>: mov %eax,%esi

0x0000000000000035 <+53>: lea 0x0(%rip),%rdi # 0x3c <main+60>

0x000000000000003c <+60>: callq 0x41 <main+65>

0x0000000000000041 <+65>: lea 0x0(%rip),%rsi # 0x48 <main+72>

0x0000000000000048 <+72>: mov %rax,%rdi

0x000000000000004b <+75>: callq 0x50 <main+80>

0x0000000000000050 <+80>: mov %rax,%rdx

0x0000000000000053 <+83>: mov -0xc(%rbp),%eax

0x0000000000000056 <+86>: mov %eax,%esi

0x0000000000000058 <+88>: mov %rdx,%rdi

0x000000000000005b <+91>: callq 0x60 <main+96>

0x0000000000000060 <+96>: lea 0x0(%rip),%rsi # 0x67 <main+103>

0x0000000000000067 <+103>: mov %rax,%rdi

0x000000000000006a <+106>: callq 0x6f <main+111>

0x000000000000006f <+111>: mov %rax,%rdx

0x0000000000000072 <+114>: mov -0x4(%rbp),%eax

0x0000000000000075 <+117>: mov %eax,%esi

0x0000000000000077 <+119>: mov %rdx,%rdi

0x000000000000007a <+122>: callq 0x7f <main+127>

0x000000000000007f <+127>: mov %rax,%rdx

0x0000000000000082 <+130>: mov 0x0(%rip),%rax # 0x89 <main+137>

0x0000000000000089 <+137>: mov %rax,%rsi

0x000000000000008c <+140>: mov %rdx,%rdi

0x000000000000008f <+143>: callq 0x94 <main+148>

0x0000000000000094 <+148>: addl $0x1,-0xc(%rbp)

0x0000000000000098 <+152>: jmp 0x20 <main+32>

0x000000000000009a <+154>: addl $0x1,-0x8(%rbp)

0x000000000000009e <+158>: jmpq 0xf <main+15>

0x00000000000000a3 <+163>: mov $0x0,%eax

0x00000000000000a8 <+168>: leaveq

0x00000000000000a9 <+169>: retq

---Type <return> to continue, or q <return> to quit---return

End of assembler dump.

(gdb)

gdb assignment4_2.o

(gdb) info functions

All defined functions:

Non-debugging symbols:

0x0000000000000000 main

0x00000000000000c2 __static_initialization_and_destruction_0(int, int)

0x000000000000010b _GLOBAL__sub_I_main

(gdb) disassemble main

Dump of assembler code for function main:

0x0000000000000000 <+0>: push %rbp

0x0000000000000001 <+1>: mov %rsp,%rbp

0x0000000000000004 <+4>: sub $0x30,%rsp

0x0000000000000008 <+8>: mov %fs:0x28,%rax

0x0000000000000011 <+17>: mov %rax,-0x8(%rbp)

0x0000000000000015 <+21>: xor %eax,%eax

0x0000000000000017 <+23>: lea 0x0(%rip),%rsi # 0x1e <main+30>

0x000000000000001e <+30>: lea 0x0(%rip),%rdi # 0x25 <main+37>

0x0000000000000025 <+37>: callq 0x2a <main+42>

0x000000000000002a <+42>: mov %rax,%rdx

0x000000000000002d <+45>: mov 0x0(%rip),%rax # 0x34 <main+52>

0x0000000000000034 <+52>: mov %rax,%rsi

0x0000000000000037 <+55>: mov %rdx,%rdi

0x000000000000003a <+58>: callq 0x3f <main+63>

0x000000000000003f <+63>: lea -0x14(%rbp),%rax

0x0000000000000043 <+67>: mov %rax,%rsi

0x0000000000000046 <+70>: lea 0x0(%rip),%rdi # 0x4d <main+77>

0x000000000000004d <+77>: callq 0x52 <main+82>

0x0000000000000052 <+82>: mov -0x14(%rbp),%edx

0x0000000000000055 <+85>: mov -0x14(%rbp),%eax

0x0000000000000058 <+88>: imul %eax,%edx

0x000000000000005b <+91>: mov -0x14(%rbp),%eax

0x000000000000005e <+94>: imul %edx,%eax

0x0000000000000061 <+97>: mov %eax,-0x14(%rbp)

0x0000000000000064 <+100>: mov -0x14(%rbp),%eax

0x0000000000000067 <+103>: cvtsi2sd %eax,%xmm0

0x000000000000006b <+107>: movsd 0x0(%rip),%xmm1 # 0x73 <main+115>

0x0000000000000073 <+115>: mulsd %xmm1,%xmm0

0x0000000000000077 <+119>: movsd %xmm0,-0x10(%rbp)

0x000000000000007c <+124>: lea 0x0(%rip),%rsi # 0x83 <main+131>

0x0000000000000083 <+131>: lea 0x0(%rip),%rdi # 0x8a <main+138>

0x000000000000008a <+138>: callq 0x8f <main+143>

0x000000000000008f <+143>: mov %rax,%rdx

0x0000000000000092 <+146>: mov -0x10(%rbp),%rax

0x0000000000000096 <+150>: mov %rax,-0x28(%rbp)

0x000000000000009a <+154>: movsd -0x28(%rbp),%xmm0

0x000000000000009f <+159>: mov %rdx,%rdi

0x00000000000000a2 <+162>: callq 0xa7 <main+167>

0x00000000000000a7 <+167>: mov $0x0,%eax

0x00000000000000ac <+172>: mov -0x8(%rbp),%rcx

0x00000000000000b0 <+176>: xor %fs:0x28,%rcx

0x00000000000000b9 <+185>: je 0xc0 <main+192>

0x00000000000000bb <+187>: callq 0xc0 <main+192>

0x00000000000000c0 <+192>: leaveq

---Type <return> to continue, or q <return> to quit---return

0x00000000000000c1 <+193>: retq

End of assembler dump.

(gdb)

gdb assignment4_3.o

(gdb) info functions

All defined functions:

Non-debugging symbols:

0x0000000000000000 main

0x000000000000018c __static_initialization_and_destruction_0(int, int)

0x00000000000001d5 _GLOBAL__sub_I_main

(gdb) disassemble main

Dump of assembler code for function main:

0x0000000000000000 <+0>: push %rbp

0x0000000000000001 <+1>: mov %rsp,%rbp

0x0000000000000004 <+4>: sub $0x20,%rsp

0x0000000000000008 <+8>: mov %fs:0x28,%rax

0x0000000000000011 <+17>: mov %rax,-0x8(%rbp)

0x0000000000000015 <+21>: xor %eax,%eax

0x0000000000000017 <+23>: movl $0x1,-0xc(%rbp)

0x000000000000001e <+30>: lea 0x0(%rip),%rsi # 0x25 <main+37>

0x0000000000000025 <+37>: lea 0x0(%rip),%rdi # 0x2c <main+44>

0x000000000000002c <+44>: callq 0x31 <main+49>

0x0000000000000031 <+49>: mov %rax,%rdx

0x0000000000000034 <+52>: mov 0x0(%rip),%rax # 0x3b <main+59>

0x000000000000003b <+59>: mov %rax,%rsi

0x000000000000003e <+62>: mov %rdx,%rdi

0x0000000000000041 <+65>: callq 0x46 <main+70>

0x0000000000000046 <+70>: lea -0x18(%rbp),%rax

0x000000000000004a <+74>: mov %rax,%rsi

0x000000000000004d <+77>: lea 0x0(%rip),%rdi # 0x54 <main+84>

0x0000000000000054 <+84>: callq 0x59 <main+89>

0x0000000000000059 <+89>: mov -0x18(%rbp),%eax

0x000000000000005c <+92>: sub $0x1,%eax

0x000000000000005f <+95>: mov %eax,-0xc(%rbp)

0x0000000000000062 <+98>: movl $0x1,-0x10(%rbp)

0x0000000000000069 <+105>: mov -0x18(%rbp),%eax

0x000000000000006c <+108>: cmp %eax,-0x10(%rbp)

0x000000000000006f <+111>: jg 0xe3 <main+227>

0x0000000000000071 <+113>: movl $0x1,-0x14(%rbp)

0x0000000000000078 <+120>: mov -0x14(%rbp),%eax

0x000000000000007b <+123>: cmp -0xc(%rbp),%eax

0x000000000000007e <+126>: jg 0x99 <main+153>

0x0000000000000080 <+128>: lea 0x0(%rip),%rsi # 0x87 <main+135>

0x0000000000000087 <+135>: lea 0x0(%rip),%rdi # 0x8e <main+142>

0x000000000000008e <+142>: callq 0x93 <main+147>

0x0000000000000093 <+147>: addl $0x1,-0x14(%rbp)

0x0000000000000097 <+151>: jmp 0x78 <main+120>

0x0000000000000099 <+153>: subl $0x1,-0xc(%rbp)

0x000000000000009d <+157>: movl $0x1,-0x14(%rbp)

0x00000000000000a4 <+164>: mov -0x10(%rbp),%eax

0x00000000000000a7 <+167>: add %eax,%eax

0x00000000000000a9 <+169>: sub $0x1,%eax

0x00000000000000ac <+172>: cmp %eax,-0x14(%rbp)

0x00000000000000af <+175>: jg 0xca <main+202>

0x00000000000000b1 <+177>: lea 0x0(%rip),%rsi # 0xb8 <main+184>

0x00000000000000b8 <+184>: lea 0x0(%rip),%rdi # 0xbf <main+191>

---Type <return> to continue, or q <return> to quit---return

0x00000000000000bf <+191>: callq 0xc4 <main+196>

0x00000000000000c4 <+196>: addl $0x1,-0x14(%rbp)

0x00000000000000c8 <+200>: jmp 0xa4 <main+164>

0x00000000000000ca <+202>: lea 0x0(%rip),%rsi # 0xd1 <main+209>

0x00000000000000d1 <+209>: lea 0x0(%rip),%rdi # 0xd8 <main+216>

0x00000000000000d8 <+216>: callq 0xdd <main+221>

0x00000000000000dd <+221>: addl $0x1,-0x10(%rbp)

0x00000000000000e1 <+225>: jmp 0x69 <main+105>

0x00000000000000e3 <+227>: movl $0x1,-0xc(%rbp)

0x00000000000000ea <+234>: movl $0x1,-0x10(%rbp)

0x00000000000000f1 <+241>: mov -0x18(%rbp),%eax

0x00000000000000f4 <+244>: sub $0x1,%eax

0x00000000000000f7 <+247>: cmp %eax,-0x10(%rbp)

0x00000000000000fa <+250>: jg 0x171 <main+369>

0x00000000000000fc <+252>: movl $0x1,-0x14(%rbp)

0x0000000000000103 <+259>: mov -0x14(%rbp),%eax

0x0000000000000106 <+262>: cmp -0xc(%rbp),%eax

0x0000000000000109 <+265>: jg 0x124 <main+292>

0x000000000000010b <+267>: lea 0x0(%rip),%rsi # 0x112 <main+274>

0x0000000000000112 <+274>: lea 0x0(%rip),%rdi # 0x119 <main+281>

0x0000000000000119 <+281>: callq 0x11e <main+286>

0x000000000000011e <+286>: addl $0x1,-0x14(%rbp)

0x0000000000000122 <+290>: jmp 0x103 <main+259>

0x0000000000000124 <+292>: addl $0x1,-0xc(%rbp)

0x0000000000000128 <+296>: movl $0x1,-0x14(%rbp)

0x000000000000012f <+303>: mov -0x18(%rbp),%eax

0x0000000000000132 <+306>: sub -0x10(%rbp),%eax

0x0000000000000135 <+309>: add %eax,%eax

0x0000000000000137 <+311>: sub $0x1,%eax

0x000000000000013a <+314>: cmp %eax,-0x14(%rbp)

0x000000000000013d <+317>: jg 0x158 <main+344>

0x000000000000013f <+319>: lea 0x0(%rip),%rsi # 0x146 <main+326>

0x0000000000000146 <+326>: lea 0x0(%rip),%rdi # 0x14d <main+333>

0x000000000000014d <+333>: callq 0x152 <main+338>

0x0000000000000152 <+338>: addl $0x1,-0x14(%rbp)

0x0000000000000156 <+342>: jmp 0x12f <main+303>

0x0000000000000158 <+344>: lea 0x0(%rip),%rsi # 0x15f <main+351>

0x000000000000015f <+351>: lea 0x0(%rip),%rdi # 0x166 <main+358>

0x0000000000000166 <+358>: callq 0x16b <main+363>

0x000000000000016b <+363>: addl $0x1,-0x10(%rbp)

0x000000000000016f <+367>: jmp 0xf1 <main+241>

0x0000000000000171 <+369>: mov $0x1,%eax

0x0000000000000176 <+374>: mov -0x8(%rbp),%rcx

0x000000000000017a <+378>: xor %fs:0x28,%rcx

0x0000000000000183 <+387>: je 0x18a <main+394>

---Type <return> to continue, or q <return> to quit---

gdb assignment4_4.o

(gdb) info function

All defined functions:

Non-debugging symbols:

0x0000000000000000 main

0x0000000000000147 __static_initialization_and_destruction_0(int, int)

0x0000000000000190 _GLOBAL__sub_I_main

(gdb) disassemble main

Dump of assembler code for function main:

0x0000000000000000 <+0>: push %rbp

0x0000000000000001 <+1>: mov %rsp,%rbp

0x0000000000000004 <+4>: sub $0x30,%rsp

0x0000000000000008 <+8>: mov %fs:0x28,%rax

0x0000000000000011 <+17>: mov %rax,-0x8(%rbp)

0x0000000000000015 <+21>: xor %eax,%eax

0x0000000000000017 <+23>: movq $0x0,-0x20(%rbp)

0x000000000000001f <+31>: movq $0x1,-0x18(%rbp)

0x0000000000000027 <+39>: lea 0x0(%rip),%rsi # 0x2e <main+46>

0x000000000000002e <+46>: lea 0x0(%rip),%rdi # 0x35 <main+53>

0x0000000000000035 <+53>: callq 0x3a <main+58>

0x000000000000003a <+58>: mov %rax,%rdx

0x000000000000003d <+61>: mov 0x0(%rip),%rax # 0x44 <main+68>

0x0000000000000044 <+68>: mov %rax,%rsi

0x0000000000000047 <+71>: mov %rdx,%rdi

0x000000000000004a <+74>: callq 0x4f <main+79>

0x000000000000004f <+79>: lea -0x28(%rbp),%rax

0x0000000000000053 <+83>: mov %rax,%rsi

0x0000000000000056 <+86>: lea 0x0(%rip),%rdi # 0x5d <main+93>

0x000000000000005d <+93>: callq 0x62 <main+98>

0x0000000000000062 <+98>: mov -0x28(%rbp),%rax

0x0000000000000066 <+102>: test %rax,%rax

0x0000000000000069 <+105>: je 0xf2 <main+242>

0x000000000000006f <+111>: mov -0x28(%rbp),%rcx

0x0000000000000073 <+115>: movabs $0x6666666666666667,%rdx

0x000000000000007d <+125>: mov %rcx,%rax

0x0000000000000080 <+128>: imul %rdx

0x0000000000000083 <+131>: sar $0x2,%rdx

0x0000000000000087 <+135>: mov %rcx,%rax

0x000000000000008a <+138>: sar $0x3f,%rax

0x000000000000008e <+142>: sub %rax,%rdx

0x0000000000000091 <+145>: mov %rdx,%rax

0x0000000000000094 <+148>: mov %rax,-0x10(%rbp)

0x0000000000000098 <+152>: mov -0x10(%rbp),%rdx

0x000000000000009c <+156>: mov %rdx,%rax

0x000000000000009f <+159>: shl $0x2,%rax

0x00000000000000a3 <+163>: add %rdx,%rax

0x00000000000000a6 <+166>: add %rax,%rax

0x00000000000000a9 <+169>: sub %rax,%rcx

0x00000000000000ac <+172>: mov %rcx,%rax

0x00000000000000af <+175>: mov %rax,-0x10(%rbp)

0x00000000000000b3 <+179>: mov -0x10(%rbp),%rax

0x00000000000000b7 <+183>: imul -0x18(%rbp),%rax

0x00000000000000bc <+188>: add %rax,-0x20(%rbp)

---Type <return> to continue, or q <return> to quit---return

0x00000000000000c0 <+192>: shlq -0x18(%rbp)

0x00000000000000c4 <+196>: mov -0x28(%rbp),%rcx

0x00000000000000c8 <+200>: movabs $0x6666666666666667,%rdx

0x00000000000000d2 <+210>: mov %rcx,%rax

0x00000000000000d5 <+213>: imul %rdx

0x00000000000000d8 <+216>: sar $0x2,%rdx

0x00000000000000dc <+220>: mov %rcx,%rax

0x00000000000000df <+223>: sar $0x3f,%rax

0x00000000000000e3 <+227>: sub %rax,%rdx

0x00000000000000e6 <+230>: mov %rdx,%rax

0x00000000000000e9 <+233>: mov %rax,-0x28(%rbp)

0x00000000000000ed <+237>: jmpq 0x62 <main+98>

0x00000000000000f2 <+242>: lea 0x0(%rip),%rsi # 0xf9 <main+249>

0x00000000000000f9 <+249>: lea 0x0(%rip),%rdi # 0x100 <main+256>

0x0000000000000100 <+256>: callq 0x105 <main+261>

0x0000000000000105 <+261>: mov %rax,%rdx

0x0000000000000108 <+264>: mov -0x20(%rbp),%rax

0x000000000000010c <+268>: mov %rax,%rsi

0x000000000000010f <+271>: mov %rdx,%rdi

0x0000000000000112 <+274>: callq 0x117 <main+279>

0x0000000000000117 <+279>: mov %rax,%rdx

0x000000000000011a <+282>: mov 0x0(%rip),%rax # 0x121 <main+289>

0x0000000000000121 <+289>: mov %rax,%rsi

0x0000000000000124 <+292>: mov %rdx,%rdi

0x0000000000000127 <+295>: callq 0x12c <main+300>

0x000000000000012c <+300>: mov $0x0,%eax

0x0000000000000131 <+305>: mov -0x8(%rbp),%rsi

0x0000000000000135 <+309>: xor %fs:0x28,%rsi

0x000000000000013e <+318>: je 0x145 <main+325>

0x0000000000000140 <+320>: callq 0x145 <main+325>

0x0000000000000145 <+325>: leaveq

0x0000000000000146 <+326>: retq

End of assembler dump.

(gdb)

Unformatted Attachment Preview

CS 410 Binary to C++ Activity Template Janera Dobson Southern New Hampshire University CS-410-T3249 File One Step 2: Explain the functionality of the blocks of assembly code. Blocks of Assembly Code movl $0x1,-0x8(%rbp) cmpl $0x9,-0x8(%rbp) jg 0xa3 movl $0x1,-0xc(%rbp) cmpl $0x9,-0xc(%rbp) jg 0x9a mov -0x8(%rbp),%eax imul -0xc(%rbp),%eax mov %eax,-0x4(%rbp) mov -0x8(%rbp),%eax lea 0x0(%rip),%rdi # 0x3c callq 0x41 lea 0x0(%rip),%rsi # 0x48 mov %rax,%rdi callq 0x50 mov %rax,%rdx mov -0xc(%rbp),%eax mov %eax,%esi mov %rdx,%rdi callq 0x60 lea 0x0(%rip),%rsi # 0x67 mov %rax,%rdi callq 0x6f mov %rax,%rdx mov -0x4(%rbp),%eax mov %rdx,%rdi callq 0x7f mov %rax,%rdx mov 0x0(%rip),%rax # 0x89 mov %rdx,%rdi callq 0x94 addl $0x1,-0xc(%rbp) jmp 0x20 addl $0x1,-0x8(%rbp) jmpq 0xf leaveq retq Explanation of Functionality Assign the value 1 to -8(%rbp) Compare the value in -8(%rbp) with 9 Jump to address Assign the value 1 to %rbp Compare the value 1 to 9 in %rbp Jump to address Move the value of x at -8(%rbp) to %eax Multiply value at -8(%rbp) by %eax Move %eax new value to -4(%rbp) Move -8(%rbp) to %eax Now move %eax to %esi to prepare for print Callq prints statement on x = a * i This enters the loop again in which values are moved to %rdx, then %eax, to %esi, and then %rdi in order to call callq function to print values on stack console. Add the value 1 to -8(%rbp) with 9 Jumps to address Add 1 to -8(%rbp) If -8(%rbp) is less than or equal to 9 jump to address Return and exit program Step 4: Convert the assembly code to C++ code. #include using namespace std; int main() { int number, i, a, x; for (a = 1; a <= 9; a++) { for (i = 1; i <= 9; i++){ x = a * i; cout << a << " * " << i << " = " << x << endl; } } return 0; } Step 5: Explain how the C++ code performs the same tasks as the blocks of assembly code. Blocks of Assembly Code C++ Code Explanation of Functionality File Two Step 2: Explain the functionality of the blocks of assembly code. Blocks of Assembly Code Explanation of Functionality Step 4: Convert the assembly code to C++ code. Step 5: Explain how the C++ code performs the same tasks as the blocks of assembly code. Blocks of Assembly Code C++ Code Explanation of Functionality File Three Step 2: Explain the functionality of the blocks of assembly code. Blocks of Assembly Code Explanation of Functionality Step 4: Convert the assembly code to C++ code. Step 5: Explain how the C++ code performs the same tasks as the blocks of assembly code. Blocks of Assembly Code C++ Code Explanation of Functionality File Four Step 2: Explain the functionality of the blocks of assembly code. Blocks of Assembly Code Explanation of Functionality Step 4: Convert the assembly code to C++ code. Step 5: Explain how the C++ code performs the same tasks as the blocks of assembly code. Blocks of Assembly Code gdb assignment4_1.o (gdb) info functions All defined functions: C++ Code Explanation of Functionality Non-debugging symbols: 0x0000000000000000 main 0x00000000000000aa __static_initialization_and_destruction_0(int, int) 0x00000000000000f3 _GLOBAL__sub_I_main (gdb) disassemble main Dump of assembler code for function main: 0x0000000000000000 <+0>: push %rbp 0x0000000000000001 <+1>: mov %rsp,%rbp 0x0000000000000004 <+4>: sub $0x10,%rsp 0x0000000000000008 <+8>: movl $0x1,-0x8(%rbp) 0x000000000000000f <+15>: cmpl $0x9,-0x8(%rbp) 0x0000000000000013 <+19>: jg 0xa3 0x0000000000000019 <+25>: movl $0x1,-0xc(%rbp) 0x0000000000000020 <+32>: cmpl $0x9,-0xc(%rbp) 0x0000000000000024 <+36>: jg 0x9a 0x0000000000000026 <+38>: mov -0x8(%rbp),%eax 0x0000000000000029 <+41>: imul -0xc(%rbp),%eax 0x000000000000002d <+45>: mov %eax,-0x4(%rbp) 0x0000000000000030 <+48>: mov -0x8(%rbp),%eax 0x0000000000000033 <+51>: mov %eax,%esi 0x0000000000000035 <+53>: lea 0x0(%rip),%rdi # 0x3c 0x000000000000003c <+60>: callq 0x41 0x0000000000000041 <+65>: lea 0x0(%rip),%rsi # 0x48 0x0000000000000048 <+72>: mov %rax,%rdi 0x000000000000004b <+75>: callq 0x50 0x0000000000000050 <+80>: mov %rax,%rdx 0x0000000000000053 <+83>: mov -0xc(%rbp),%eax 0x0000000000000056 <+86>: mov %eax,%esi 0x0000000000000058 <+88>: mov %rdx,%rdi 0x000000000000005b <+91>: callq 0x60 0x0000000000000060 <+96>: lea 0x0(%rip),%rsi # 0x67 0x0000000000000067 <+103>: mov %rax,%rdi 0x000000000000006a <+106>: callq 0x6f 0x000000000000006f <+111>: mov %rax,%rdx 0x0000000000000072 <+114>: mov -0x4(%rbp),%eax 0x0000000000000075 <+117>: mov %eax,%esi 0x0000000000000077 <+119>: mov %rdx,%rdi 0x000000000000007a <+122>: callq 0x7f 0x000000000000007f <+127>: mov %rax,%rdx 0x0000000000000082 <+130>: mov 0x0(%rip),%rax # 0x89 0x0000000000000089 <+137>: mov %rax,%rsi 0x000000000000008c <+140>: mov %rdx,%rdi 0x000000000000008f <+143>: callq 0x94 0x0000000000000094 <+148>: addl $0x1,-0xc(%rbp) 0x0000000000000098 <+152>: jmp 0x20 0x000000000000009a <+154>: addl $0x1,-0x8(%rbp) 0x000000000000009e <+158>: jmpq 0xf 0x00000000000000a3 <+163>: mov $0x0,%eax 0x00000000000000a8 <+168>: leaveq 0x00000000000000a9 <+169>: retq ---Type to continue, or q to quit---return End of assembler dump. (gdb) gdb assignment4_2.o (gdb) info functions All defined functions: Non-debugging symbols: 0x0000000000000000 main 0x00000000000000c2 __static_initialization_and_destruction_0(int, int) 0x000000000000010b _GLOBAL__sub_I_main (gdb) disassemble main Dump of assembler code for function main: 0x0000000000000000 <+0>: push %rbp 0x0000000000000001 <+1>: mov %rsp,%rbp 0x0000000000000004 <+4>: sub $0x30,%rsp 0x0000000000000008 <+8>: mov %fs:0x28,%rax 0x0000000000000011 <+17>: mov %rax,-0x8(%rbp) 0x0000000000000015 <+21>: xor %eax,%eax 0x0000000000000017 <+23>: lea 0x0(%rip),%rsi # 0x1e 0x000000000000001e <+30>: lea 0x0(%rip),%rdi # 0x25 0x0000000000000025 <+37>: callq 0x2a 0x000000000000002a <+42>: mov %rax,%rdx 0x000000000000002d <+45>: mov 0x0(%rip),%rax # 0x34 0x0000000000000034 <+52>: mov %rax,%rsi 0x0000000000000037 <+55>: mov %rdx,%rdi 0x000000000000003a <+58>: callq 0x3f 0x000000000000003f <+63>: lea -0x14(%rbp),%rax 0x0000000000000043 <+67>: mov %rax,%rsi 0x0000000000000046 <+70>: lea 0x0(%rip),%rdi # 0x4d 0x000000000000004d <+77>: callq 0x52 0x0000000000000052 <+82>: mov -0x14(%rbp),%edx 0x0000000000000055 <+85>: mov -0x14(%rbp),%eax 0x0000000000000058 <+88>: imul %eax,%edx 0x000000000000005b <+91>: mov -0x14(%rbp),%eax 0x000000000000005e <+94>: imul %edx,%eax 0x0000000000000061 <+97>: mov %eax,-0x14(%rbp) 0x0000000000000064 <+100>: mov -0x14(%rbp),%eax 0x0000000000000067 <+103>: cvtsi2sd %eax,%xmm0 0x000000000000006b <+107>: movsd 0x0(%rip),%xmm1 # 0x73 0x0000000000000073 <+115>: mulsd %xmm1,%xmm0 0x0000000000000077 <+119>: movsd %xmm0,-0x10(%rbp) 0x000000000000007c <+124>: lea 0x0(%rip),%rsi # 0x83 0x0000000000000083 <+131>: lea 0x0(%rip),%rdi # 0x8a 0x000000000000008a <+138>: callq 0x8f 0x000000000000008f <+143>: mov %rax,%rdx 0x0000000000000092 <+146>: mov -0x10(%rbp),%rax 0x0000000000000096 <+150>: mov %rax,-0x28(%rbp) 0x000000000000009a <+154>: movsd -0x28(%rbp),%xmm0 0x000000000000009f <+159>: mov %rdx,%rdi 0x00000000000000a2 <+162>: callq 0xa7 0x00000000000000a7 <+167>: mov $0x0,%eax 0x00000000000000ac <+172>: mov -0x8(%rbp),%rcx 0x00000000000000b0 <+176>: xor %fs:0x28,%rcx 0x00000000000000b9 <+185>: je 0xc0 0x00000000000000bb <+187>: callq 0xc0 0x00000000000000c0 <+192>: leaveq ---Type to continue, or q to quit---return 0x00000000000000c1 <+193>: retq End of assembler dump. (gdb) gdb assignment4_3.o (gdb) info functions All defined functions: Non-debugging symbols: 0x0000000000000000 main 0x000000000000018c __static_initialization_and_destruction_0(int, int) 0x00000000000001d5 _GLOBAL__sub_I_main (gdb) disassemble main Dump of assembler code for function main: 0x0000000000000000 <+0>: push %rbp 0x0000000000000001 <+1>: mov %rsp,%rbp 0x0000000000000004 <+4>: sub $0x20,%rsp 0x0000000000000008 <+8>: mov %fs:0x28,%rax 0x0000000000000011 <+17>: mov %rax,-0x8(%rbp) 0x0000000000000015 <+21>: xor %eax,%eax 0x0000000000000017 <+23>: movl $0x1,-0xc(%rbp) 0x000000000000001e <+30>: lea 0x0(%rip),%rsi # 0x25 0x0000000000000025 <+37>: lea 0x0(%rip),%rdi # 0x2c 0x000000000000002c <+44>: callq 0x31 0x0000000000000031 <+49>: mov %rax,%rdx 0x0000000000000034 <+52>: mov 0x0(%rip),%rax # 0x3b 0x000000000000003b <+59>: mov %rax,%rsi 0x000000000000003e <+62>: mov %rdx,%rdi 0x0000000000000041 <+65>: callq 0x46 0x0000000000000046 <+70>: lea -0x18(%rbp),%rax 0x000000000000004a <+74>: mov %rax,%rsi 0x000000000000004d <+77>: lea 0x0(%rip),%rdi # 0x54 0x0000000000000054 <+84>: callq 0x59 0x0000000000000059 <+89>: mov -0x18(%rbp),%eax 0x000000000000005c <+92>: sub $0x1,%eax 0x000000000000005f <+95>: mov %eax,-0xc(%rbp) 0x0000000000000062 <+98>: movl $0x1,-0x10(%rbp) 0x0000000000000069 <+105>: mov -0x18(%rbp),%eax 0x000000000000006c <+108>: cmp %eax,-0x10(%rbp) 0x000000000000006f <+111>: jg 0xe3 0x0000000000000071 <+113>: movl $0x1,-0x14(%rbp) 0x0000000000000078 <+120>: mov -0x14(%rbp),%eax 0x000000000000007b <+123>: cmp -0xc(%rbp),%eax 0x000000000000007e <+126>: jg 0x99 0x0000000000000080 <+128>: lea 0x0(%rip),%rsi # 0x87 0x0000000000000087 <+135>: lea 0x0(%rip),%rdi # 0x8e 0x000000000000008e <+142>: callq 0x93 0x0000000000000093 <+147>: addl $0x1,-0x14(%rbp) 0x0000000000000097 <+151>: jmp 0x78 0x0000000000000099 <+153>: subl $0x1,-0xc(%rbp) 0x000000000000009d <+157>: movl $0x1,-0x14(%rbp) 0x00000000000000a4 <+164>: mov -0x10(%rbp),%eax 0x00000000000000a7 <+167>: add %eax,%eax 0x00000000000000a9 <+169>: sub $0x1,%eax 0x00000000000000ac <+172>: cmp %eax,-0x14(%rbp) 0x00000000000000af <+175>: jg 0xca 0x00000000000000b1 <+177>: lea 0x0(%rip),%rsi # 0xb8 0x00000000000000b8 <+184>: lea 0x0(%rip),%rdi # 0xbf ---Type to continue, or q to quit---return 0x00000000000000bf <+191>: callq 0xc4 0x00000000000000c4 <+196>: addl $0x1,-0x14(%rbp) 0x00000000000000c8 <+200>: jmp 0xa4 0x00000000000000ca <+202>: lea 0x0(%rip),%rsi # 0xd1 0x00000000000000d1 <+209>: lea 0x0(%rip),%rdi # 0xd8 0x00000000000000d8 <+216>: callq 0xdd 0x00000000000000dd <+221>: addl $0x1,-0x10(%rbp) 0x00000000000000e1 <+225>: jmp 0x69 0x00000000000000e3 <+227>: movl $0x1,-0xc(%rbp) 0x00000000000000ea <+234>: movl $0x1,-0x10(%rbp) 0x00000000000000f1 <+241>: mov -0x18(%rbp),%eax 0x00000000000000f4 <+244>: sub $0x1,%eax 0x00000000000000f7 <+247>: cmp %eax,-0x10(%rbp) 0x00000000000000fa <+250>: jg 0x171 0x00000000000000fc <+252>: movl $0x1,-0x14(%rbp) 0x0000000000000103 <+259>: mov -0x14(%rbp),%eax 0x0000000000000106 <+262>: cmp -0xc(%rbp),%eax 0x0000000000000109 <+265>: jg 0x124 0x000000000000010b <+267>: lea 0x0(%rip),%rsi # 0x112 0x0000000000000112 <+274>: lea 0x0(%rip),%rdi # 0x119 0x0000000000000119 <+281>: callq 0x11e 0x000000000000011e <+286>: addl $0x1,-0x14(%rbp) 0x0000000000000122 <+290>: jmp 0x103 0x0000000000000124 <+292>: addl $0x1,-0xc(%rbp) 0x0000000000000128 <+296>: movl $0x1,-0x14(%rbp) 0x000000000000012f <+303>: mov -0x18(%rbp),%eax 0x0000000000000132 <+306>: sub -0x10(%rbp),%eax 0x0000000000000135 <+309>: add %eax,%eax 0x0000000000000137 <+311>: sub $0x1,%eax 0x000000000000013a <+314>: cmp %eax,-0x14(%rbp) 0x000000000000013d <+317>: jg 0x158 0x000000000000013f <+319>: lea 0x0(%rip),%rsi # 0x146 0x0000000000000146 <+326>: lea 0x0(%rip),%rdi # 0x14d 0x000000000000014d <+333>: callq 0x152 0x0000000000000152 <+338>: addl $0x1,-0x14(%rbp) 0x0000000000000156 <+342>: jmp 0x12f 0x0000000000000158 <+344>: lea 0x0(%rip),%rsi # 0x15f 0x000000000000015f <+351>: lea 0x0(%rip),%rdi # 0x166 0x0000000000000166 <+358>: callq 0x16b 0x000000000000016b <+363>: addl $0x1,-0x10(%rbp) 0x000000000000016f <+367>: jmp 0xf1 0x0000000000000171 <+369>: mov $0x1,%eax 0x0000000000000176 <+374>: mov -0x8(%rbp),%rcx 0x000000000000017a <+378>: xor %fs:0x28,%rcx 0x0000000000000183 <+387>: je 0x18a ---Type to continue, or q to quit--- gdb assignment4_4.o (gdb) info function All defined functions: Non-debugging symbols: 0x0000000000000000 main 0x0000000000000147 __static_initialization_and_destruction_0(int, int) 0x0000000000000190 _GLOBAL__sub_I_main (gdb) disassemble main Dump of assembler code for function main: 0x0000000000000000 <+0>: push %rbp 0x0000000000000001 <+1>: mov %rsp,%rbp 0x0000000000000004 <+4>: sub $0x30,%rsp 0x0000000000000008 <+8>: mov %fs:0x28,%rax 0x0000000000000011 <+17>: mov %rax,-0x8(%rbp) 0x0000000000000015 <+21>: xor %eax,%eax 0x0000000000000017 <+23>: movq $0x0,-0x20(%rbp) 0x000000000000001f <+31>: movq $0x1,-0x18(%rbp) 0x0000000000000027 <+39>: lea 0x0(%rip),%rsi # 0x2e 0x000000000000002e <+46>: lea 0x0(%rip),%rdi # 0x35 0x0000000000000035 <+53>: callq 0x3a 0x000000000000003a <+58>: mov %rax,%rdx 0x000000000000003d <+61>: mov 0x0(%rip),%rax # 0x44 0x0000000000000044 <+68>: mov %rax,%rsi 0x0000000000000047 <+71>: mov %rdx,%rdi 0x000000000000004a <+74>: callq 0x4f 0x000000000000004f <+79>: lea -0x28(%rbp),%rax 0x0000000000000053 <+83>: mov %rax,%rsi 0x0000000000000056 <+86>: lea 0x0(%rip),%rdi # 0x5d 0x000000000000005d <+93>: callq 0x62 0x0000000000000062 <+98>: mov -0x28(%rbp),%rax 0x0000000000000066 <+102>: test %rax,%rax 0x0000000000000069 <+105>: je 0xf2 0x000000000000006f <+111>: mov -0x28(%rbp),%rcx 0x0000000000000073 <+115>: movabs $0x6666666666666667,%rdx 0x000000000000007d <+125>: mov %rcx,%rax 0x0000000000000080 <+128>: imul %rdx 0x0000000000000083 <+131>: sar $0x2,%rdx 0x0000000000000087 <+135>: mov %rcx,%rax 0x000000000000008a <+138>: sar $0x3f,%rax 0x000000000000008e <+142>: sub %rax,%rdx 0x0000000000000091 <+145>: mov %rdx,%rax 0x0000000000000094 <+148>: mov %rax,-0x10(%rbp) 0x0000000000000098 <+152>: mov -0x10(%rbp),%rdx 0x000000000000009c <+156>: mov %rdx,%rax 0x000000000000009f <+159>: shl $0x2,%rax 0x00000000000000a3 <+163>: add %rdx,%rax 0x00000000000000a6 <+166>: add %rax,%rax 0x00000000000000a9 <+169>: sub %rax,%rcx 0x00000000000000ac <+172>: mov %rcx,%rax 0x00000000000000af <+175>: mov %rax,-0x10(%rbp) 0x00000000000000b3 <+179>: mov -0x10(%rbp),%rax 0x00000000000000b7 <+183>: imul -0x18(%rbp),%rax 0x00000000000000bc <+188>: add %rax,-0x20(%rbp) ---Type to continue, or q to quit---return 0x00000000000000c0 <+192>: shlq -0x18(%rbp) 0x00000000000000c4 <+196>: mov -0x28(%rbp),%rcx 0x00000000000000c8 <+200>: movabs $0x6666666666666667,%rdx 0x00000000000000d2 <+210>: mov %rcx,%rax 0x00000000000000d5 <+213>: imul %rdx 0x00000000000000d8 <+216>: sar $0x2,%rdx 0x00000000000000dc <+220>: mov %rcx,%rax 0x00000000000000df <+223>: sar $0x3f,%rax 0x00000000000000e3 <+227>: sub %rax,%rdx 0x00000000000000e6 <+230>: mov %rdx,%rax 0x00000000000000e9 <+233>: mov %rax,-0x28(%rbp) 0x00000000000000ed <+237>: jmpq 0x62 0x00000000000000f2 <+242>: lea 0x0(%rip),%rsi # 0xf9 0x00000000000000f9 <+249>: lea 0x0(%rip),%rdi # 0x100 0x0000000000000100 <+256>: callq 0x105 0x0000000000000105 <+261>: mov %rax,%rdx 0x0000000000000108 <+264>: mov -0x20(%rbp),%rax 0x000000000000010c <+268>: mov %rax,%rsi 0x000000000000010f <+271>: mov %rdx,%rdi 0x0000000000000112 <+274>: callq 0x117 0x0000000000000117 <+279>: mov %rax,%rdx 0x000000000000011a <+282>: mov 0x0(%rip),%rax # 0x121 0x0000000000000121 <+289>: mov %rax,%rsi 0x0000000000000124 <+292>: mov %rdx,%rdi 0x0000000000000127 <+295>: callq 0x12c 0x000000000000012c <+300>: mov $0x0,%eax 0x0000000000000131 <+305>: mov -0x8(%rbp),%rsi 0x0000000000000135 <+309>: xor %fs:0x28,%rsi 0x000000000000013e <+318>: je 0x145 0x0000000000000140 <+320>: callq 0x145 0x0000000000000145 <+325>: leaveq 0x0000000000000146 <+326>: retq End of assembler dump. (gdb) ...
Student has agreed that all tutoring, explanations, and answers provided by the tutor will be used to help in the learning process and in accordance with Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Similar Questions
Related Tags

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors