Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This a homework assignment. I think I've managed to figure it out yet for some reason my solution does not work. So there is a

This a homework assignment. I think I've managed to figure it out yet for some reason my solution does not work.

So there is a linked_list of 6 nodes and my answer is a string of 6 integers separated by a space. Numbers can only range from 1 to 6.From what I understood, it all boils down to sorting my list in descending order of node values and the answer is the order of nodes.

In my case, this happens to be:

image text in transcribed

this is the dump:

Dump of assembler code for function phase_6:

=> 0x00000000004010df : push %r14

0x00000000004010e1 : push %r13

0x00000000004010e3 : push %r12

0x00000000004010e5 : push %rbp

0x00000000004010e6 : push %rbx

0x00000000004010e7 : sub $0x50,%rsp

0x00000000004010eb : lea 0x30(%rsp),%r13

0x00000000004010f0 : mov %r13,%rsi

0x00000000004010f3 : callq 0x4015aa

0x00000000004010f8 : mov %r13,%r14

0x00000000004010fb : mov $0x0,%r12d

0x0000000000401101 : mov %r13,%rbp

0x0000000000401104 : mov 0x0(%r13),%eax

0x0000000000401108 : sub $0x1,%eax

0x000000000040110b : cmp $0x5,%eax

0x000000000040110e : jbe 0x401115

0x0000000000401110 : callq 0x401574

0x0000000000401115 : add $0x1,%r12d

0x0000000000401119 : cmp $0x6,%r12d

0x000000000040111d : je 0x401141

0x000000000040111f : mov %r12d,%ebx

0x0000000000401122 : movslq %ebx,%rax

0x0000000000401125 : mov 0x30(%rsp,%rax,4),%eax

0x0000000000401129 : cmp %eax,0x0(%rbp)

0x000000000040112c : jne 0x401133

0x000000000040112e : callq 0x401574

0x0000000000401133 : add $0x1,%ebx

0x0000000000401136 : cmp $0x5,%ebx

0x0000000000401139 : jle 0x401122

0x000000000040113b : add $0x4,%r13

0x000000000040113f : jmp 0x401101

0x0000000000401141 : lea 0x48(%rsp),%rsi

0x0000000000401146 : mov %r14,%rax

0x0000000000401149 : mov $0x7,%ecx

0x000000000040114e : mov %ecx,%edx

0x0000000000401150 : sub (%rax),%edx

0x0000000000401152 : mov %edx,(%rax)

0x0000000000401154 : add $0x4,%rax

0x0000000000401158 : cmp %rsi,%rax

0x000000000040115b : jne 0x40114e

0x000000000040115d : mov $0x0,%esi

0x0000000000401162 : jmp 0x401184

0x0000000000401164 : mov 0x8(%rdx),%rdx

0x0000000000401168 : add $0x1,%eax

0x000000000040116b : cmp %ecx,%eax

0x000000000040116d : jne 0x401164

0x000000000040116f : jmp 0x401176

0x0000000000401171 : mov $0x6042f0,%edx

0x0000000000401176 : mov %rdx,(%rsp,%rsi,2)

0x000000000040117a : add $0x4,%rsi

0x000000000040117e : cmp $0x18,%rsi

0x0000000000401182 : je 0x401199

0x0000000000401184 : mov 0x30(%rsp,%rsi,1),%ecx

0x0000000000401188 : cmp $0x1,%ecx

0x000000000040118b : jle 0x401171

0x000000000040118d : mov $0x1,%eax

0x0000000000401192 : mov $0x6042f0,%edx

0x0000000000401197 : jmp 0x401164

0x0000000000401199 : mov (%rsp),%rbx

0x000000000040119d : lea 0x8(%rsp),%rax

0x00000000004011a2 : lea 0x30(%rsp),%rsi

---Type to continue, or q to quit---

0x00000000004011a7 : mov %rbx,%rcx

0x00000000004011aa : mov (%rax),%rdx

0x00000000004011ad : mov %rdx,0x8(%rcx)

0x00000000004011b1 : add $0x8,%rax

0x00000000004011b5 : cmp %rsi,%rax

0x00000000004011b8 : je 0x4011bf

0x00000000004011ba : mov %rdx,%rcx

0x00000000004011bd : jmp 0x4011aa

0x00000000004011bf : movq $0x0,0x8(%rdx)

0x00000000004011c7 : mov $0x5,%ebp

0x00000000004011cc : mov 0x8(%rbx),%rax

0x00000000004011d0 : mov (%rax),%eax

0x00000000004011d2 : cmp %eax,(%rbx)

0x00000000004011d4 : jge 0x4011db

0x00000000004011d6 : callq 0x401574

0x00000000004011db : mov 0x8(%rbx),%rbx

0x00000000004011df : sub $0x1,%ebp

0x00000000004011e2 : jne 0x4011cc

0x00000000004011e4 : add $0x50,%rsp

0x00000000004011e8 : pop %rbx

0x00000000004011e9 : pop %rbp

0x00000000004011ea : pop %r12

0x00000000004011ec : pop %r13

0x00000000004011ee : pop %r14

0x00000000004011f0 : retq

End of assembler dump.

(gdb) x /4x $rbx 0x6042f0 (gdb) x /4x 0x00604330 0x604330 (gdb) x /4x 0x00604310 0x604310 (gdb) x /4x 0x00604340 0x604340 (gdb) x /4x 0x00604320 0x604320 (gdb) x /4x 0x00604300 0x604300 (gdb) 0x0000005b 0x000002d7 0x000001c8 0x000001c8 0x000002cc 0x000000e1 0x0000013b 0x00000001 0x00000005 0x00000003 0x00000003 0x00000006 0x00000004 0x00000002 0x00604330 0x00604310 0x00604340 0x00604340 0x00604320 0x00604300 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 (gdb) x /4x $rbx 0x6042f0 (gdb) x /4x 0x00604330 0x604330 (gdb) x /4x 0x00604310 0x604310 (gdb) x /4x 0x00604340 0x604340 (gdb) x /4x 0x00604320 0x604320 (gdb) x /4x 0x00604300 0x604300 (gdb) 0x0000005b 0x000002d7 0x000001c8 0x000001c8 0x000002cc 0x000000e1 0x0000013b 0x00000001 0x00000005 0x00000003 0x00000003 0x00000006 0x00000004 0x00000002 0x00604330 0x00604310 0x00604340 0x00604340 0x00604320 0x00604300 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000

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

More Books

Students also viewed these Databases questions

Question

Distinguish between hearing and listening.

Answered: 1 week ago