I'm currently trying to get into OS development, mostly following the articles and tutorials from OSDev. As os now, I have multiple assembly files I need to e.g. enable paging and setting up long mode.
While the only assembler code I'm certain about needs to be separated in an own file is the boot assembly file, I'm curious about the practices and "standards" how to deal with assembly in an OS written in C. Is it convenient to separate assembler from C or is there a reason why e.g. Linux wraps most of the assembly code inside C functions and calls them using the asm volatile
directives?
I don't see much difference, as you can return results from assembly by moving the value into the eax
register, or when using asm
and asm volatile
, you can specify parameters and output operands where to store the result. However, you always need to separate multiple instructions by using \n
or \n\t
.
As of now, I only found out about the different ways of dealing with assembly in a larger project, but not why some chose to separate assembly code from C or C++, and why some chose to use inline assembly thorough the whole program.
I hope you could give me some insights about the different ways used regarding this topic.