Hello everyone,
I started learning assembly yesterday. Yes maybe I chose a wrong guide but I have a little problem here. It's about getting some integers without a newline. That is probably very easy to solve but I was searching for a solution for a few hours and no results. Well, enough about that, let's get to the point.
I need to get an input cointaining some integers, but I need them to be without a newline. I wrote a small loop to do that for me, I think everything is OK, yet it gives me a "Segmentation fault".
CPU: i486
Assembler: NASM version 0.99.06-20071101
OS: Ubuntu 8.04 (Hardy)
Linux kernel: 2.6.24-22-generic
Commands: nasm -f elf kalkulator.asm
ld -s -o kalkulator kalkulator.o
%define lf 10
bufor1: times 40 db 0
bufor2: times 40 db 0
wczytuj:
xor esi, esi
mov esi, 0
petla:
push eax
push ebx
push ecx
push edx
mov eax, 3
mov ebx, 0
lea ecx, [bufor1]
mov edx, 1
mov al, [bufor1]
cmp al, lf
jne _wczytuj_zapisz
push esi
push eax
int 80h
pop eax
pop esi
pop edx
pop ecx
pop ebx
pop eax
cmp al, lf
jne petla
ret
_wczytuj_zapisz:
mov [bufor2+esi], al
inc esi
ret
Note that I am a complete newbie in assembly, so please try to explain my mistakes as precisely and as easy to understand as possible. I'd be happy if you correct the whole code, but I'll accept any help.
Thanks
-Marek