Firstly, if this is in the wrong location then I apologise.
I was wondering, does anyone have links to tutorials or example code which I could look at? I am interested in programming my kernel in C, but I need to find a way to jump from my 512-byte bootloader to another ASM file, which then loads the C code. Yes, it is a simple task, but I really am stuck.
ASM to C
Re: ASM to C
All versions of C support something called "function pointers". They are ugly things to declare, but it sounds like they would work for your purpose. You would need to use casting to declare a constant address to be a function pointer, and then call it. Alternately, to use single lines of ASM code within a C program you can use compiler-dependent thingies called "inline ASM". All compilers support it, but it ties your code to that compiler forever. Last, you can write ASM routines in files that are completely in assembler, compile it with the assembler, and then use the loader/linker to link that ASM code together into one executable with other C programs.
So, start with the search terms: inline assembly (in the osdev wiki works well), and "function pointers". Linking ASM object files requires a knowledge of your assembler and linker.
So, start with the search terms: inline assembly (in the osdev wiki works well), and "function pointers". Linking ASM object files requires a knowledge of your assembler and linker.
Re: ASM to C
You may need to "pause" the OS Development task and learn 'C' first. There are lots of tutorials available across the web so, grab one and get going. Once you feel you are ready, you can continue smooth 'OS Development'.
Generally, 'Learning language with OS Development' is considered BAD IDEA so, I'm recommending it. But again, that's your choice.
Best Regards,
Chandra
Generally, 'Learning language with OS Development' is considered BAD IDEA so, I'm recommending it. But again, that's your choice.
Best Regards,
Chandra
Programming is not about using a language to solve a problem, it's about using logic to find a solution !