fastcall, calling conventions and etc.

  • From: "Littlefield, Tyler" <tyler@xxxxxxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Tue, 18 Jan 2011 12:13:50 -0700

This will probably end up being a Sina-question, but I figured someone else may have some input as well. So here goes. I'm curious what the binafits to using fastcall (where function arguments will get put in registers, rather than pushed to the stack) are, especially in low-level programming. I ask this because I am working on a boot loader and kernel to go along with said boot loader, and I would like to optomize the low-level work (such as video and i/o to and from ports, etc) as much as possible. If something uses fastcall, their arguments are found in eax, ebx, ecx, etc correct? Also, since the this pointer is passed in c++, will that also be passed rather than pushed onto the stack? Are there other calling conventions worth learning? Eventually I would like to allow c++ to be used in the kernel (which could be kind of nice), but I"m not to that point. I just want to pave the way, persey. I guess my last question is this. I've read that class functions are inline, are not inline, are sometimes inline, etc. So lets say I have the following:

class person
{
std::string _name;
public:
Person(const std::string &name)
{
_name = name;
}
std::string GetName() const
{
return _name;
}
}
Does it make sense to require a call (and also to copy the strings in the ctor) for just a single line of code? Is there a quicker way, perhaps that will do this, rather than something like:
push this
push name
call ctor
pop name
pop this
To me, that's like 4 instructions that could have been avoided, and you end up with way way more when you use things like the windows API, that requires everything plus your social security number and date of birth in about 50 parameters.

--

Thanks,
Ty

__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts:

  • » fastcall, calling conventions and etc. - Littlefield, Tyler