Well, your basic problem is that "input" is characters. These characters are integers, of course, but they aren't the integers the characters represent. For example, if the user enters "20" (which I guess is what you're looking for), what's in the buffer is 0x32 ("2"), 0x30 ("0")... and a linefeed (0xA) 'cause sys_read doesn't return until it sees one.
section .bss
input resb 2
section .text
global _start
_start:
mov eax, 3
mov ebx, 1
mov ecx, input
mov edx, 5
int 0x80
Whoa! You've only reserved two bytes for your buffer and allowed the user to put (up to) five bytes into it. That's a "buffer overflow"! Very bad! Won't do any harm in this case, since there's nothing after your buffer, but don't do it! How many characters do you actually want to allow the user to enter? A full 32-bit integer will take (up to) 10 characters to represent. You probably want one extra to hold the linefeed. You may want to allow a minus sign, if you're going to handle signed integers. So you want to reserve (at least) that many bytes in your input buffer.
If the user keeps typing more than what you've allowed in edx (up until "enter" is hit, remember), the excess stays in the OS's input buffer (won't overwrite your buffer - edx bytes maximum), and will be read by the next sys_read - will end up on the command line, in this case. We really should flush the (OS's) input buffer at this point, but to "keep it simple" we can ignore that for now... (this is called "teaching sloppy solutions to beginners" - my bad!)
At this point, eax will contain the number of characters actually entered (including the linefeed). This can be useful to note/save, but we don't really need it.
mov eax, [input]
The input buffer will hold, for this example, say 0x32, 0x30, 0xA. Putting this in eax (as 0x000A3032) is not too useful. What you want to do is get one character at a time, subtract '0' (0x30, 48 decimal) to convert it from a character to the number it represents, multiply a "result so far" by ten, and add in the number... until done.
Since we want the result in eax, we might as well use that as a "result so far" - zero it first. Since ecx already points to our input buffer, we might as well use that. We want a full 32-bit register to add to our "result so far", but we only want a byte in it, with the upper bits zeroed. "movzx" will do that, but we can do it another way...
xor eax, eax ; (or mov eax, 0) zero "result so far"
xor ebx, ebx ; zero upper bits of ebx for our character
mov esi, 10 ; for a multiplier
top:
mov bl, [ecx] ; get a character
inc ecx ; get ready for the next one
cmp bl, '0' ; is it a valid decimal digit?
jb done
cmp bl, '9'
ja done
mul esi ; eax * esi -> edx:eax
add eax, ebx ; valid digit - add to "result so far"
jmp top ; do another
done:
; now you can compare integer to integer!
cmp eax, 20 ; This is what I cannot get to work, it never compares it to 20 even if i enter 20 as input
je next
That's untested and probably has errors - I'm kinda distracted just now - but that's the general idea...
Best,
Frank