Define Own Types in C

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
pskyboy

Define Own Types in C

Post by pskyboy »

Hey Guys

Does anyone know how C or C++ (im guessing it will be the same) create there types. What i mean is when you do

Code: Select all

UINT uiTest
What does this compile into i have decompiled a very simple c file but am having trouble spotting it. I am guessing it will just add it to the stack and increment the pointer is this right.

Basically what i want to do is write a piece of assembler to make a 64bit and 128bit data type.

Peter
Slasher

Re:Define Own Types in C

Post by Slasher »

hello,
that will be a problem and difficult on the intel processors, at least in the i386 family cause
registers are 32bits in size so in effect you will have to find away to combine 2 registers (64bits) or 4 registers(128 bits). plus there is a limited number of them to do that and some instructions use specific registers for calculations and results, so the registers you use for your combinations ie EAX could be changed by an instruction :(
what exactly do you want this 64 and 128 bits data type for?
jrfritz

Re:Define Own Types in C

Post by jrfritz »

Well...you could do some tricky interger stuff and combine the values one after another to get huge ints...I mean as big as you want...but it is very tricky...
Slasher

Re:Define Own Types in C

Post by Slasher »

hi,
personally don't think its worth the effort. just use structs for whatever it is you are trying to do with 64 and 128 bits. after all
typedef struct
{
unsigned long hi_part;
unsigned long Low_part;
}64_data;
this struct is 64 bits in size ie 2 32bit fields!
but we can't help until we know what is to be done with the 64 and 128 bits data types! :(
jrfritz

Re:Define Own Types in C

Post by jrfritz »

Since we don't know what he/she wants....

What in the world would 64 ints be worth? If you need big numbers, than a linked list would be good...
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Define Own Types in C

Post by Pype.Clicker »

most GCC implementations have a LONG LONG type that is intented to be 64bits wide on 32bits implementations... however, some basic arithmetic operations (like multiplications, etc.) will require a runtime support
pskyboy

Re:Define Own Types in C

Post by pskyboy »

Thats what i was hoping actually that there was a built in type. I am used to visual c++ and in there you had __int64, and __int96.

My main reason is so that i can deal with
a) A GPR pointer which is 48bits
b) I want to use certain things as 64bit so that when i port it to Athlon 64 i can just change a define to unsigned int on a 64bit compiler

Peter (im a He)
jrfritz

Re:Define Own Types in C

Post by jrfritz »

(I forgot your name was Peter)
Post Reply