When a member function of an object is called, the this pointer is passed as an argument on the stack (The order depends on the calling convention) and a lot of work is done on the this pointer to check which object is calling the function.
Standard Functions just need a simple CALL instruction.
Printf V/s Cout [DreamInCode.net] Which one is better?
#17
Posted 08 May 2008 - 11:47 PM
born2c0de, on 8 May, 2008 - 07:01 AM, said:
When a member function of an object is called, the this pointer is passed as an argument on the stack
In some architectures, I suppose it is; but when using Visual C++ on X86 or IA64, __thiscall says that the this pointer arrives at the calling function arrives in the ECX register.
born2c0de, on 8 May, 2008 - 07:01 AM, said:
Which architecture presents (The order depends on the calling convention) and a lot of work is done on the this pointer to check which object is calling the function.
born2c0de, on 8 May, 2008 - 07:01 AM, said:
Standard Functions just need a simple CALL instruction.
#18
Posted 04 November 2008 - 01:49 AM
nice article...
good to see diff b/w printf and cout
good to see diff b/w printf and cout
#20
Posted 16 April 2009 - 09:31 PM
Just on the fact that cout is an object with a bunch of member functions and printf is a function... Bit confused, how big is the function of printf ? I mean when you pass paramters such as %d, %i ... what then is called to manipulate the data ? This might be something very simple, however i really would like to know .... like when printf(%d, something) is called - is a function called within printf to change the "something" and return it to printf to print ?
I guess this could be traced in olley or ida, however i am unsure
I guess this could be traced in olley or ida, however i am unsure
#21
Posted 18 April 2009 - 06:15 PM
bbq, on 16 Apr, 2009 - 08:31 PM, said:
.... like when printf(%d, something) is called - is a function called within printf to change the "something" and return it to printf to print ?
I guess this could be traced in olley or ida, however i am unsure
I guess this could be traced in olley or ida, however i am unsure
The answer is that, yes: printf() calls other functions to do formatting for each of the escape codes it uses. Depending on the implementation, it might do so directly--but it probably calls another helper function that lets the library share code. printf(), fprintf(), sprintf(), vsprintf(), and so on, all use the same formatting escapes, so they're all implemented by shared routines ... in a well-built library, anyhow.
#22
Posted 19 April 2009 - 01:12 AM
mikeblas, on 18 Apr, 2009 - 05:15 PM, said:
bbq, on 16 Apr, 2009 - 08:31 PM, said:
.... like when printf(%d, something) is called - is a function called within printf to change the "something" and return it to printf to print ?
I guess this could be traced in olley or ida, however i am unsure
I guess this could be traced in olley or ida, however i am unsure
The answer is that, yes: printf() calls other functions to do formatting for each of the escape codes it uses. Depending on the implementation, it might do so directly--but it probably calls another helper function that lets the library share code. printf(), fprintf(), sprintf(), vsprintf(), and so on, all use the same formatting escapes, so they're all implemented by shared routines ... in a well-built library, anyhow.
Cheers for the info
|
|







MultiQuote







|