| | |
Getting input without newline
Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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:
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 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 asm Syntax (Toggle Plain Text)
%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
Last edited by venomxxl; Feb 2nd, 2009 at 12:45 pm.
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.
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.
Assembly Syntax (Toggle Plain Text)
cmp al, lf jne _wczytuj_zapisz
Assembly Syntax (Toggle Plain Text)
wczytuj_zapisz: mov [bufor2+esi], al inc esi ret
![]() |
Similar Threads
- warning:no newline at end of file (C)
- Reading in file input up to newline (C++)
- string input not working as expected (C++)
- Help with input (C)
- how to place a specific info from input file (C)
- i want the user to enter an input without obligating him to press enter (C++)
Other Threads in the Assembly Forum
- Previous Thread: Passing Variables
- Next Thread: hex->ascii question
Views: 651 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Assembly
3d 68hc11 6811 80386 :( adress array asm assembler assembly boot bootloader buffer compression cursor debug directory division docs dos draw emulator endtask error exceptions file int10h integer intel interrupt interrupts language loop newbie nohau osdevelopment print program range read remainder shape string text theory tsr x86





