Question: Modify the Y86-64 code for the sum function (Figure 4.6) to implement a function absSum that computes the sum of absolute values of an array.

Modify the Y86-64 code for the sum function (Figure 4.6) to implement a function absSum that computes the sum of absolute values of an array. Use a conditional jump instruction within your inner loop.

Figure 4.6

x86-64 code 1 2 3 4 5 6 7 8 9 10 11 1 2 3 5 6 7 8 9 10 11 long sun(long start, long count) start in Zrdi,

x86-64 code 1 2 3 4 5 6 7 8 9 10 11 1 2 3 5 6 7 8 9 10 11 long sun(long start, long count) start in Zrdi, count in rai sun: 12 13 14 movl So, Zeax L2 jap Y86-64 code L3: addq addq subq .L2: testq %rai, %rai jne .L3 rep: ret (%rdi). %rax $8. %rdi $1. %rai irmovq $8.%r8 irnova $1.%r9 xorq %rax. %rax andq %rsi,%rsi jap test loop: armov (%rd1).Xr10. addq %r10. %rax addq %r8.%rdi subq %r9.%rs1 test: sum - 0 Goto test jne loop ret loop: long sun(long start, long count) start in %rdi, count in rai sun: Add start to u start++ count- test: Test sum If 1-0, goto loop Return Constant 8 Constant 1 sum - 0 Set CC Goto test Get start Add to num start++ count. Set CC Stop when 0 Return

Step by Step Solution

3.32 Rating (149 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

This problem gives you a chance to try your hand at writing assembly code 1 2 3 4 5 6 7 8 9 ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Systems A Programmers Perspective Questions!