flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
vid
1. Linux kernel doesn't have heap manager (common memory allocation mechanism for applications) built in. Instead, it expects every application to link to libc. Best way is to link your asm source with libc and use libc for I/O.
2. Again, use libc if you can. You will save yourself many problems. |
|||
![]() |
|
klavs.pr
So... I have to use malloc() and free() to manage memory. But another question - can I use getchar() or fgetc(FILE*) is more suitable for asm? It is written, that in c stdin is already initialized (when program starts), so I guess stdin is not initialized in asm and I can't use getchar() directly. Or can I?
|
|||
![]() |
|
vid
Your program definitively should invoke libc startup code to initialize stdin. However I have to admit I don't know how dynamic linking works in Linux (I assume you are linking to glibc dynamically).
|
|||
![]() |
|
klavs.pr
Ok, thanks vid.
I did it just like libcdemo example does it.(i guess it is not really dinamic linking) Now i have memory allocated and freed, and getchar() works without any manual initialization. But the problem remains - this function does not read single char AND then stop reading. |
|||
![]() |
|
vid
If you *really* only want to read char from stdin, you could use handle I/O instead of stream I/O (read() from handle 1, instead of fgetc() from FILE* stdin). But I would suggest to rather look into proper linux libc usage than workarounding problems.
|
|||
![]() |
|
Tyler
You could link your program with crtbegin.o and crtend.o. These can be found in /usr/lib/gcc/?/?/.
|
|||
![]() |
|
rugxulo
Dumb answer, but hey, what'd you expect from me?
![]() Code: db 30000 dup(0) Or preferably even in .bss or wherever. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.