Q:

Assembly strlen input prob

I'm really new to x86 assembly programming and ignorant of its complexity.
Suppose I have a variable declared under section .bss
name resb 20

And I want to get a name input from the user:
; gets name
mov eax, 3
mov ebx, 0
mov ecx, name
int 80h

I'm just wondering if the length of the input via stdin is stored in one of the registers? Does it count including the carriage return? the length value is stored in al I suppose? or bl? If so, can I then store it like this?
mov byte[nameLen], al

where nameLen is declared under section .bss like this
nameLen resb 1

I would pretty much like to re-print the string input like this:
; excludes the carriage return from count
dec byte[nameLen]

mov eax, 4
mov ebx, 1
mov ecx, name
mov edx, nameLen
int 80h

Please help! Thanks!

Im using x86 Ubuntu.

A:

Here is two examples easy to understand on how to use stdin and stdout in assembly :

STDIN You were right, the input length is stored in one of the register :
; read a byte from stdin
mov eax, 3           ; 3 is recognized by the system as meaning "read"
mov ebx, 0           ; read from standard input
mov ecx, name        ; address to pass to
mov edx, 1           ; input length (one byte)
int 0x80             ; call the kernel

If I remember right, stdin does not take in count the carriage return. But you should test it to be sure.
STDOUT Your implementation was correct, but I give you mine with the comment :
; print a byte to stdout
mov eax, 4           ; the system interprets 4 as "write"
mov ebx, 1           ; standard output (print to terminal)
mov ecx, name        ; pointer to the value being passed
mov edx, 1           ; length of output (in bytes)
int 0x80             ; call the kernel

I would suggest you to comment a maximum what you are doing in assembly because it is really hard to come back on a code you did months ago... 
EDIT :
You can retrieve the number of characters read with the eax register.

Integer values and memory addresses are returned in the EAX register.

The sys_read function return the number of characters read so, this number is in eax after the call of the function.
Here is an example of program using eax :
section .data
        nameLen: db 20

section .bss
        name:    resb 20

section .text
        global _start

_exit:
        mov eax, 1                ; exit
        mov ebx, 0                ; exit status
        int 80h

_start:
        mov eax, 3                ; 3 is recognized by the system as meaning "read"
        mov ebx, 0                ; read from the standard input
        mov ecx, name             ; address to pass to
        mov edx, nameLen          ; input length
        int 80h

        cmp eax, 0                ; compare the returned value of the function with 0
        je  _exit                 ; jump to _exit if equal

        mov edx, eax              ; save the number of bytes read
                                  ; it will be passed to the write function

        mov eax, 4                ; the system interprets 4 as "write"
        mov ebx, 1                ; standard output (print to terminal)
        mov ecx, name             ; pointer to the value being passed
        int 80h

        jmp _start                ; Infinite loop to continue reading on the standard input

This simple program continue reading on the standard input and print the result on the standard output.

