Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
this is assembled as:
make a call to the address in memory location main, using prefix ES
and executed as
target = memory(es * 16 + main)
push ip
mov ip, target
the architecture has no direct opcode for call es:_main (without [ ] ), so either:
- You use a direct far call and either force the same segment (or fix the instruction using self-modyfing code, yuck)
- You create a far pointer in memory and use call far [structure]
- You push everything into place and use RETF
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
I've since been able to boot into the kernel successfully - and use my assembly functions - but the new problem is how to get a byte argument from Turbo C? I look at the disassembly and there is nothing at all pushed onto the stack before my assembly functions run. Why is this happening?
Is it possible to see the code for that part - I don't see any pushes in your code.
If you mean that you would like to pass an argument to '_main', you will need to manually push your arguments before caling it. I use GCC which pushes from right to left, but I guess all C compilers are the same in this respect
If you are expecting arguments from a previous boot loader, you need to retrieve them *before* you move the stack pointer!
AJ wrote:I use GCC which pushes from right to left, but I guess all C compilers are the same in this respect
They need not be. Obviously there is the convention to use whatever the system libraries expect, but since we're talking about OS development, calling conventions could be left-to-right, unpadded, register passing or whatever...
Every good solution is obvious once you've found it.
Sorry, the code above is not the code I was referencing! I've looked at other code to be linked with 'tlink' and they all use the calling convention I would normally use. Here's my assembly:
New problem: functions can only be called once before the linker doesn't work properly anymore!! It says 'fixup overflow' and none of my functions work anymore. Any ideas?