Logo 
Search:

Assembly Language Answers

Ask Question   UnAnswered
Home » Forum » Assembly Language       RSS Feeds
  Question Asked By: Art Style   on Nov 12 In Assembly Language Category.

  
Question Answered By: Sergey Kamenev   on Nov 12

;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

Share: 

 
 


Tagged: