This is apparently a very popular assignment lately! There are a couple of similar questions (in "example code") recently, which may also help you.
%macro print 2
mov eax,4
mov ebx,1
mov ecx,%1
mov edx,%2
int 80h
%endmacro
%macro read 2
mov eax,3
mov ebx,0
mov ecx,%1
mov edx,%2
int 80h
%endmacro
SECTION .data
msg: db "enter count",10
len: equ $-msg
msg1: db "enter nos",10
len1: equ $-msg1
SECTION .bss
array: resb 10
count: resb 1 ; one byte!
SECTION .text
global _start
_start:
print msg,len
read count,1
mov eax,[count] ; move one byte -plus three garbage bytes - into eax
sub eax,30h ; convert character to number
mov edi,eax ; move the number to edi
ld:
print edi,1 ; print one character from address "number" - unlikely to be valid memory
print msg1,len1
mov esi,array
loop:
read esi,1
inc esi
dec edi
jnz loop
mov eax,1
mov ebx,0
int 80h
sys_read, from stdin, does not return until the "enter" key is hit. If the user types "1"(enter) (and edx is 1), the "1" goes into our buffer and the linefeed (0Ah) remains in the OS's input queue. On the next sys_read, the linefeed is read, no waiting, and goes in our buffer. This is why you're only accepting half of the expected number of numbers. I have no idea why it works in gdb.
Then you convert the character to a number, and try to use this number as the address of a buffer for sys_write. This simply isn't going to work - sys_write expects the address of a buffer in ecx, not some number to print.
I'll look at this in more detail later, but I think that's the essence of what's wrong with it.
Best,
Frank