Sunday, July 29, 2007
Wireless enabled home :-)
I recently switched from a desktop machine at work to a laptop. They issued me a HP Compaq nc6320 laptop. Still trying to get accustomed to the laptop keyboard and the mouse as well. I think it will take me some time, so please excuse any typos in this article. This reminds me of the message "Excuse typos, sent from wireless device", that one typically gets for emails sent from a wireless device like blackberry.
Given that I have a laptop at my disposal, the next thing I have done is setup a wireless router at my home. This gives me the freedom to work from any room in the house while being connected to the internet. I purchased a DLink DI 524 (DLink DI 624 is still not available in India, mentioned by the DLink distributor). Setting up the router was fairly straight forward. It had a neat and clean setup wizard and paper documentation explaining the steps. The router provides 4 LAN points in addition to wireless support. This allows me to connect my existing desktop at home to the wireless router.I think wireless technology is neat and it amazes me! Probably you want to try something similar at your home.
Tuesday, July 10, 2007
Calling conventions for functions.
I have been wanting to write this blog about calling conventions for functions, ever since I have been hit by it. Around one year back, we faced a very peculiar problem wherein calling a certain function caused a GPF [general protection fault]. Painful analysis of the problem (spread over more than a couple of days) revealed that the issue was related to incorrect function calling convention.
I will talk about calling conventions with primary focus on Windows platform and MS VC++ compiler. Function calling convention determines the following:
Now let us take a look at the common calling conventions:
I will talk about calling conventions with primary focus on Windows platform and MS VC++ compiler. Function calling convention determines the following:
- the order in which function arguments are pushed on the stack
- who is responsible for clearing the call stack (i.e. removing arguments) at the end of the call.
- any name-decoration that the compiler uses
Now let us take a look at the common calling conventions:
- cdecl [C calling convention]- Arguments are pushed on the stack from right to left. Thus, the first argument to the function is placed on top of the stack. This allows for passing variable number of arguments on the stack. Stack is cleaned up by the caller. This implies large executables, since each function call includes code to clean the stack. Underscore "_" character is prefixed to the function name.
- stdcall [Standard calling convention] - Typically used to for Win32 API functions. Arguments are pushed on the stack from right to left. The callee is responsible for stack cleanup. An underscore "_" character is prefixed to the function name, followed by "@" which is followed by number of bytes (in decimal) in the argument list.
- fastcall [ Fast calling convention] - Arguments are passed using registers and stack as well. The called functions is responsible to clean the stack. An "@" sign is prefixed to the function name and the "@" sign is followed by the number of bytes (in decimal) in the parameter list.
Labels: programming