Question: 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

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!