You could write the following code:
.386
.model flat, stdcall
.stack 1000h
include \masm32\include\masm32rt.inc
.data
array db 1, 1 ; defining the array
arrlength db 2 ; array length
consoleOutHandle dd ?
bytesWritten dd ?
message db "------",13,10
lmessage dd 8 ; print declarations
.code
main proc
mov ebx, offset array ; array location
mov eax, 0 ; total
mov ecx, 0 ; i
loopLabel:
push ecx
mov ecx, 2
mov edx, 0
mul ecx ; eax = eax * 2
pop ecx
add ebx, ecx ; ebx is pointing to array[i]
add al, byte ptr [ebx]
sub ebx, ecx ; resetting ebx
inc ecx
cmp cl, byte ptr [arrlength] ; checking if i is bigger or equal to the length
jb loopLabel
; the print section
invoke dwtoa, eax, offset message
INVOKE GetStdHandle, STD_OUTPUT_HANDLE
mov consoleOutHandle, eax
mov edx,offset message
pushad
mov eax, offset message
INVOKE WriteConsoleA, consoleOutHandle, edx, eax, offset bytesWritten, 0
popad
invoke ExitProcess, 0
main endp
end main
; 00F9FC60
This works, but depending on which environment you're running it, you might need to change the print section to run in a different manner.