Q:

Nasm add value from register to array

I'm really new to assembly, especially NASM syntax, but I want to learn. My problem is that I didn't understand how to add values from a register, in my case edx, to an array.
I have a part of code that print the array that seems to work well:
print_array:
    mov ecx,32;move array length to ecx
    jmp iterate_array
iterate_array:
    mov eax,[result+ecx];move value from result+ecx into eax
    push    ecx;save ecx on stack
    push    eax;push & print eax
    push    formatin
    call    printf
    add esp,8       ;
    pop ecx
    dec ecx
    cmp ecx,0       ;
    jnz iterate_array

This part of code seems to work well. But the problem is when I'm trying to add a number in the array. I tried in the same manner:
xor ecx,ecx
jmp loop    
loop:
        xor edx,edx
        div ebx
        mov [result+ecx],edx
        inc ecx
        cmp eax,0       ;compare the quotient with 0;
        jnz loop

This 2 parts of code are from a simple program that should convert a decimal number to binary. The idea is that in loop I just divide eax to ebx and I want to store the remainder in the result array. 
But it seems that the method that I used doesn't work!
Results after running the program:
if I enter the number 2=> in loop eax is 2, in binary 0010 but the result is:
00000000000000000000000000000001
for number 3 =>in loop eax is 3, in binary 0011 but the result is:
00000000000000000000000000000001
for number 4=> in loop eax is 4, in binary 0100 but the result is:
0000000000000000000000000000001256
The problem is that I don't understand how to add the remainder from edx to array in loop. I thought that the method that I use in iterate_array, which seems to work ok ( display an array of 32 zeroes), should be enough.
Array was declared in .data section as:
section .data
result times 32 db  0

A:

The strange output from your program stems from the fact that  
mov eax,[result+ecx];move value from result+ecx into eax

reads garbage from the memory behind your RESULT buffer.  
You say the program changes decimal to binary. So I think you use EBX=2 resulting in a remainder of 0 or 1
Change this line  
mov ecx,32;move array length to ecx

to mov ecx,31 and make use of byte registers where appropriate. 
The answer you've provided yourself introduces a potential problem. Why do you ADD the remainder to the RESULT buffer in stead of using MOV ?

