Page 1 of 1
Define Own Types in C
Posted: Sun Dec 08, 2002 1:59 pm
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
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
Re:Define Own Types in C
Posted: Sun Dec 08, 2002 2:20 pm
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?
Re:Define Own Types in C
Posted: Sun Dec 08, 2002 3:42 pm
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...
Re:Define Own Types in C
Posted: Sun Dec 08, 2002 3:59 pm
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!
Re:Define Own Types in C
Posted: Sun Dec 08, 2002 4:03 pm
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...
Re:Define Own Types in C
Posted: Mon Dec 09, 2002 6:40 am
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
Re:Define Own Types in C
Posted: Mon Dec 09, 2002 11:17 am
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)
Re:Define Own Types in C
Posted: Mon Dec 09, 2002 1:37 pm
by jrfritz
(I forgot your name was Peter)