Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

section .text global _start ;must be declared for linker (ld) _start: mov eax,3 ;number bytes to be summed mov ebx,0 ;EBX will store the sum

section .text

global _start ;must be declared for linker (ld)

_start:

mov eax,3 ;number bytes to be summed

mov ebx,0 ;EBX will store the sum

mov ecx, x ;ECX will point to the current element to be summed

top: add ebx, [ecx]

add ecx,1 ;move pointer to next element

dec eax ;decrement counter

jnz top ;if counter not 0, then loop again

done:

add ebx, '0'

mov [sum], ebx ;done, store result in "sum"

display:

mov edx,1 ;message length

mov ecx, sum ;message to write

mov ebx, 1 ;file descriptor (stdout)

mov eax, 4 ;system call number (sys_write)

int 0x80 ;call kernel

mov eax, 1 ;system call number (sys_exit)

int 0x80 ;call kernel

section .data

global x

x:

db 2

db 4

db 3

sum:

db 0

Click here to compile and execute assembly code.

Change the program to display F as a sum of the array.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

0764549634, 9780764549632

More Books

Students also viewed these Databases questions