I have got a very interesting problem..

problem is:

there is a dword array.

Array dword 99999999, 11111111, 22222222, 33333333

how can we find the sum of all these members and display it as a string.

that is

Array[0]+Array[1]+Array[2]+Array[3] = ?

and result of this addition has to displayed as String.

bye

problem is:

there is a dword array.

Array dword 99999999, 11111111, 22222222, 33333333

how can we find the sum of all these members and display it as a string.

that is

Array[0]+Array[1]+Array[2]+Array[3] = ?

and result of this addition has to displayed as String.

bye

This homework? Anyway I don't mind helping with homework, just won't do it for you.

Basically, if its a small array who's size you know befor hand then the answer is simple.

.data

Array dd 1111,9999,2222

.code

mov eax,Array[0]

add eax,Array[4]

add eax,Array[8]

invoke SomethingToTurnEaxIntoAString,......

If its a big array then the problem is more interesting as you need to use a loop. Read the ASMINTRO.hlp that come with Masm32 to learn how to do that :) . Then simply add up the numbers through the loop and after the loop convert them to a string.

Basically, if its a small array who's size you know befor hand then the answer is simple.

.data

Array dd 1111,9999,2222

.code

mov eax,Array[0]

add eax,Array[4]

add eax,Array[8]

invoke SomethingToTurnEaxIntoAString,......

If its a big array then the problem is more interesting as you need to use a loop. Read the ASMINTRO.hlp that come with Masm32 to learn how to do that :) . Then simply add up the numbers through the loop and after the loop convert them to a string.

E?in, Solving homework now are we? tsk,tsk! :grin: Hope he learned something.

What the hell, this works too.. I wonder why.. hehe :)

me a couple of min's to find out on my own( tsk,tsk ).

What the hell, this works too.. I wonder why.. hehe :)

```
```

xor eax,eax

mov eax,[Array+0*4]

add eax,[Array+1*4]

add eax,[Array+2*4]

add eax,[Array+3*4]

invoke dwtoa,eax,addr ArrayStr ;<--- Convert's into a string

This does exactly the same operation.. ;)
```
```

xor eax,eax

mov eax,[Array+0]

add eax,[Array+2+2]

add eax,[Array+2+4+2]

add eax,[Array+4+2+2+4]

invoke dwtoa,eax,addr ArrayStr ;<--- Convert's into a string

**NOTE:**The funny part is that I actually didnt know this until he asked the question. And it tookme a couple of min's to find out on my own( tsk,tsk ).