Answered step by step
Verified Expert Solution
Question
1 Approved Answer
section .data arr dd 1,2,3,4 ;given array len equ $-arr ;length of array sum dd 0 ;variable to store sum disp_int db %d,0,10 ;for display
section .data arr dd 1,2,3,4 ;given array len equ $-arr ;length of array sum dd 0 ;variable to store sum disp_int db "%d",0,10 ;for display using printf section .text extern printf ;for getting printf function global main ;declaring scope of main main: xor edx,edx ;to make it zero mov ebx,4 ;to get length by dividing eax mov eax,len ;stroing length in eax div ebx mov ebx,0 ;sum will be stored here mov ecx,arr ;address of array top: add ebx, [ecx] ;Value in the array is added to ebx add ecx,4 ;move pointer to next element dec eax ;decrement counter jnz top ;if counter not 0, then loop again mov [sum], ebx ;done, store result in "sum" display: push dword[sum] ;Value in sum is pushed onto stack push disp_int call printf ;Printf is call add esp,8 ;Stack gets emptied ret
What does this mean?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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