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

I believe the code listed below is giving you oyur segmentation fault.
When the branch is taken you are not poping your stack and the return address is burried under everything you pushed. You should change your label to. It should be something short but descriptive. A lot of people won't even take time to look at code if it is confusing.

cmp     al, lf        
jne     _wczytuj_zapisz
wczytuj_zapisz:        
mov     [bufor2+esi], al        
inc     
esi        ret
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.