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 move instruction within your inner loop.

Figure 4.6

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

x86-64 code T 2 3 4 5 6 7 8 9 10 11 1 2 3 5 6 7 8 10 long sun(long start, long count) start in %rdi, count in rai sun: Y86-64 code 11 12 13 nov1 so. %eax jap .L2 L3: addq addq subq .L2: testq %rai, %rai jne L3 rep: ret (%rdi). %rax $8, %rdi $1. %rsi irmovq $8.%re irmovq $1,%r9 xorq %rax. %rax andq %rsi,%rsi jap test loop: mrmov (Zrd1). %r10 addq %r10. %rax addq %r8.%rdi subq %r9,%rsi test: jne ret sum - 0 Goto test loop loop: long sun(long start, long count) start in Zrdi, count in irsi sun: Add start to sun start++ count- tent: Tent sun If 1-0, goto loop Return Constant 8 Constant 1 Set CC Goto test Get start Add to sun start++ count- Set CC Stop when 0 Return

Step by Step Solution

3.44 Rating (160 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 with ... 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!