flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Extern C, anyone? |
Author |
|
j.vimal 22 Mar 2006, 10:38
Hi there
All you need to do is make a wrapper in Assembly. That would do. Proceed like this: Code: Make an ASM file like: [BITS 32] ;If you are already in PMode, NASM syntax. use32 for FASM. extern _kernel_main entry start ;kernel_main is your C function. Note that ;There is a preceding '_'. Because, the C compiler (gcc) ;Adds '_' to all functions in the object file. ;Dunno why. You? start: call _kernel_main hlt ;Not necessary though. Thats it. Now compile your C code, and just do a linking, putting the above file above all others. Hope this helps! Vimal |
|||
22 Mar 2006, 10:38 |
|
Nyrre 01 Apr 2006, 18:46
Wow! Thanks. That helped me alot!
|
|||
01 Apr 2006, 18:46 |
|
Nyrre 02 Apr 2006, 14:14
But I've heard that if you program a kernel with c, you can't use stardard libraries (like stdio.h etc.). Is that true?
|
|||
02 Apr 2006, 14:14 |
|
Borsuc 05 Apr 2006, 18:44
Quite true, because the standard library is not magical..
printf for example, in Windows it calls different API calls. In Linux it calls Linux specific functions. That's why you can't use it. Unless you design one yourself for your OS, of course. Hey, I code some projects in C, but I don't use the standard library, because it bloats my programs and I don't have control over it it's not that difficult without it |
|||
05 Apr 2006, 18:44 |
|
Nyrre 26 Apr 2006, 12:31
Oh, could you tell me how to write programs in C without using the standard libraries? I thought that it was impossible.
|
|||
26 Apr 2006, 12:31 |
|
silkodyssey 26 Apr 2006, 19:01
Considering that you want to write your os in C and not assembly I think this forum may not be the best one for you. For questions on the C language you would be better served by comp.lang.c. For information on coding on OS you could (and should) try.
http://www.osdever.net/index.php http://www.nondot.org/sabre/os/articles alt.os.development _________________ silkodyssey |
|||
26 Apr 2006, 19:01 |
|
rugxulo 26 Apr 2006, 21:43
Nyrre wrote: Oh, could you tell me how to write programs in C without using the standard libraries? I thought that it was impossible. Not exactly OS-related, but this is the only example that I can think of at the moment: Richard Heathfield wrote: An MS-DOS implementation of John Conway's "Game of Life" using no headers, no libraries, no assembly language, no nothing - it's just raw C code. (see wbods50.c) |
|||
26 Apr 2006, 21:43 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.