mov eax, 3 ; sys_read
mov ebx,0 ; stdin
mov ecx, input2
mov edx, 2 ; one digit and the linefeed
int 80h
mov eax, [input2] ; one digit and the linefeed
; xor eax,eax ; make sure upper bytes are clear
; mov al, [input2]
; or
; movzx eax, byte [input2]
; does the same thing
sub eax, '0' ; convert ascii to decimal
imul eax ; do you really want imul? result might be negative?
add eax, '0' ;convert decimal to ascii ; (for printf)?
push eax
push sqr_msg
call printf
add esp, 8
Suppose you type "5" (enter). What goes in your buffer is 35h 0Ah. On x86, multi-byte numbers are stored little endian. So when you do "mov eax, [input2]" eax is 00000A35h. If there was cruft after input2, the upper bytes might not be zero. You subtract '0', so 0A05h (at least). Squaring that does not give the number you mention, so I deduce you did not type "5"... but it's close.
If you typed anything greater than "3", it'll be two digits, so adding '0' may not cover it. Since you're passing this squared number to printf, which does the "number to ascii" for you, you don't want to do that anyway.
You could "pop eax" (twice) if you wanted to get your number back. C functions return their value in eax. The return value from printf isn't usually interesting but sometimes it is. You might want to check the return value from scanf, for example, to make sure the user hasn't entered garbage. It is usual to "remove" the parameters from the stack by adding to esp, but you can pop if you want to.
If you're going to link this with ld (which I do not particularly recommend) you'll need to tell ld where to find the correct interpreter /dynamic linker - this is what your executable uses to find and load libc- (-I/lib/ld-linux.so.2 on my system - again) and you'll have to tell ld "-lc" so it knows where to look for scanf and printf.
Easier, perhaps, to...
nasm -f elf32 math.asm
gcc -m32 driver.c math.o -o math
gcc knows what to tell ld.
You can make it a freestanding program, but you'll need to provide an exit... and an entrypoint. I ASSume that "asm_main" comes with a prolog and epilog.
Best,
Frank