Search: | |||||

| ||||

Home » Forum » Assembly Language | RSS Feeds |

Develop an 8086 assembly program that calculate the sum of both positive and negative

elements of a signed integer array.

Both the array and the two result variables (negative_sum_result and positive_sum_result) are stored in

memory.

;Tested in FASM

format PE console

include 'win32a.inc'

mov esi,nD

mov ecx,[qcnD]

mov [negative_sum_result],0

mov [positive_sum_result],0

mSum:

cmp dword [esi],0

jg mNotNeg

mov eax,[negative_sum_result]

add eax,dword [esi]

mov [negative_sum_result],eax

mNotNeg:

cmp dword [esi],0

jl mNotPos

mov eax,[positive_sum_result]

add eax,dword [esi]

mov [positive_sum_result],eax

mNotPos:

add esi,4

loop mSum

invoke ExitProcess,0

nD dd 1,-2,-3,4,5,-6,-7,8,9,10

qcnD dd ($-nD)/4

negative_sum_result dd ?

positive_sum_result dd ?

include 'API\kernel32.inc'

data import

library kernel32,'KERNEL32.DLL'

end data

Didn't find what you were looking for?
Find more on Compute the sum of both positive and negative elements of an array
Or get search suggestion and latest updates.

Related Topics:

- Ratio of positive and negative text in learning dataset for text classification?
- Comparison of String to an element of an Array of Strings does not
- how i can Creat Desplay Sort Insert Delete element from Array
- Addition of two 4-element word arrays in decimal
- Array to array direct transfer in VB
- Array of Arrays
- C: Find the longest series of even and positive numbers
- if condition with negative value
- Change every second column to a negative number
- Write a shell program to find the sum of the series sum=1 + 3 + 5 + 7 + …+ n
- Code for Write a shell program to find the sum of the series sum=1 + 5 + 9 + ...+ n in Unix
- Calculate Total Sum
- Sum colunm total in repeater
- sum of amount deliverd group
- count the sum of a column
- SUM content of rows
- custom Sum function?
- Summing a range of variable size
- Loop, sum values and paste
- VBA code to sum
- sum in columns
- Summing on varying number of rows in Excel using VBA
- Summing a range
- getting the sum of the last 20 cells
- Conditional Summing