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.
You're popping the return IP that's on the stack, not what you want. Use registers for function calls, it works better if you don't understand how to manipulate and work with the stack. And even more so in a bootloader, since it's smaller.
EDIT: Oh, and your mov al,1 before read_sector is probably being trashed by either read_sector or lba_to_chs.
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
;prepare params for fun
mov ax,10
mov dl, 2
call calc_third_param
call fun
The problem has been, that changing registers in calc_third_param destroyed my params for "fun". Well you can first call calc_third_param and then set ax and dl, but even with this you can get tricky problems in some cases.
Troy Martin wrote:EDIT: Oh, and your mov al,1 before read_sector is probably being trashed by either read_sector or lba_to_chs.
Oh yes I saved al until I thought, that it's not necessary..
Cjreek wrote:The problem has been, that changing registers in calc_third_param destroyed my params for "fun". Well you can first call calc_third_param and then set ax and dl, but even with this you can get tricky problems in some cases.
pusha and popa. Remember that popa pops ALL general-purpose registers off the stack, so you have to save any return values.
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.