Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.



This topic is 6279 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well, writing a program in the first place is quite enough overhead for the system

Well, here's some casting I did and dissasembled:

void main(void)
float a = 7.45;
int b = 8;
char c = '*';

float d = (float)b;
float e = (float)c;

int f = (int)a;
int g = (int)c;

char h = (char)a;
char i = (char)b;


1: void main(void)
2: {
0040E090 push ebp
0040E091 mov ebp,esp
0040E093 sub esp,28h
3: float a = 7.45;
0040E096 mov dword ptr [a],40EE6666h
4: int b = 8;
0040E09D mov dword ptr [b],8
5: char c = '*';
0040E0A4 mov byte ptr [c],2Ah
7: float d = (float)b;
0040E0A8 fild dword ptr [b]
0040E0AB fstp dword ptr [d]
8: float e = (float)c;
0040E0AE movsx eax,byte ptr [c]
0040E0B2 mov dword ptr [ebp-28h],eax
0040E0B5 fild dword ptr [ebp-28h]
0040E0B8 fstp dword ptr [e]
10: int f = (int)a;
0040E0BB fld dword ptr [a]
0040E0BE call __ftol(0x004010ec)
0040E0C3 mov dword ptr [f],eax
11: int g = (int)c;
0040E0C6 movsx ecx,byte ptr [c]
0040E0CA mov dword ptr [g],ecx
13: char h = (char)a;
0040E0CD fld dword ptr [a]
0040E0D0 call __ftol(0x004010ec)
0040E0D5 mov byte ptr [h],al
14: char i = (char)b;
0040E0D8 mov dl,byte ptr [b]
0040E0DB mov byte ptr [i],dl
15: }
0040E0DE mov esp,ebp
0040E0E0 pop ebp
0040E0E1 ret

The lines with numbers are C code, so you can observe the correspondance.

Edited by - Zipster on September 8, 2001 5:43:43 PM

Share this post

Link to post
Share on other sites
Casting only has overhead (in the compiled code) when it causes a conversion. All those _ftol calls are expensive. And the filds aren't too great either. They convert integers to floating point and vice-versa.

Casting pointer types around is just instructions for the compiler.

Stupid designs have the most overhead.

Polymorphism and inheritence have very, very little overhead on a 'wintel' system.

If you're concerned about the overhead of a virtual method, you shouldn't be calling a function in the first place.

Magmai Kai Holmlor
- Not For Rent

Edited by - Magmai Kai Holmlor on September 9, 2001 12:41:27 AM

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!