Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
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
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
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started