Question: SEGMENTATION ERROR I DONT KNOW WHY ASSEMBLY DEBUGGER SAYS THAT LINE IS WRONG. IMG PROVIDED . data seed: . quad 0 . text . global

SEGMENTATION ERROR I DONT KNOW WHY ASSEMBLY DEBUGGER SAYS THAT LINE IS WRONG. IMG PROVIDED
.data
seed:
.quad 0
.text
.global randint
randint:
movq seed(%rip),%rax
movabsq $6364136223846793005,%rbx
movabsq $1442695040888963407,%rcx
imulq %rbx
addq %rcx,%rax
movq %rax, seed(%rip)
ret
.global fill_array
fill_array:
movq %rsi, %rcx # rcx = number of elements
testq %rcx,%rcx
jz .done_fill
.fill_loop:
call randint
andq $0xff,%rax # limit to range -128 to 127
subq $128,%rax
movq %rax, (%rdi) # store in array
addq $8,%rdi # move to next element
loop .fill_loop
.done_fill:
ret
.global dot
dot:
xorq %rax, %rax
xorq %rcx,%rcx
.dot_loop:
cmpq %rdx,%rcx # compare rcx with length of arrays (rdx)
jge .done_dot
movq (%rdi,%rcx,8),%r8 # load elements from array 1
imulq (%rsi,%rcx,8) # multiply with corresponding element from array 2
addq %r8,%rax # accumulate result
incq %rcx # increment counter
jmp .dot_loop
.done_dot:
ret
.global dot_struct
dot_struct:
xorq %rax, %rax
xorq %rcx,%rcx
.struct_loop:
cmpq %rsi, %rcx # compare rcx with length of struct array (rsi)
jge .done_struct
movq (%rdi,%rcx,16),%r8 # load first element of struct pair
movq 8(%rdi,%rcx,16),%r9 # load second element of struct pair
imulq %r9,%r8 # multiply elements
addq %r8,%rax # accumulate result
incq %rcx # increment counter
jmp .struct_loop
.done_struct:
ret
 SEGMENTATION ERROR I DONT KNOW WHY ASSEMBLY DEBUGGER SAYS THAT LINE

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!