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
text
global randint
randint:
movq seedriprax
movabsq $rbx
movabsq $rcx
imulq rbx
addq rcxrax
movq rax, seedrip
ret
global fillarray
fillarray:
movq rsi, rcx # rcx number of elements
testq rcxrcx
jz donefill
fillloop:
call randint
andq $xffrax # limit to range to
subq $rax
movq rax, rdi # store in array
addq $rdi # move to next element
loop fillloop
donefill:
ret
global dot
dot:
xorq rax, rax
xorq rcxrcx
dotloop:
cmpq rdxrcx # compare rcx with length of arrays rdx
jge donedot
movq rdi,rcxr # load elements from array
imulq rsi,rcx # multiply with corresponding element from array
addq rrax # accumulate result
incq rcx # increment counter
jmp dotloop
donedot:
ret
global dotstruct
dotstruct:
xorq rax, rax
xorq rcxrcx
structloop:
cmpq rsi, rcx # compare rcx with length of struct array rsi
jge donestruct
movq rdi,rcxr # load first element of struct pair
movq rdi,rcxr # load second element of struct pair
imulq rr # multiply elements
addq rrax # accumulate result
incq rcx # increment counter
jmp structloop
donestruct:
ret
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
