In ASM the BOOL C type is a byte ?

I got a C function to convert in ASM following this :

PWCHAR, PWCHAR, BOOL, DWORD, and so on...

must i write

function_name PROTO :DWORD, :DWORD, :BYTE, :DWORD, and so on... ????
Posted on 2002-04-24 16:07:49 by Djizeus
A bool in C (at least MSVC) is a byte, however a BOOL (note the caps) is typedef'd as a DWORD in the win32api headers.

Thomas
Posted on 2002-04-24 16:20:14 by Thomas
So this is a DWORD...

Thx.
Posted on 2002-04-24 16:23:16 by Djizeus
You've already got the answer, but to elaborate...

bool is not a C type, it's a new type added by C++ and yes, it's a byte. Why they didn't make it a bit I don't know. :)

BOOL is a bit more problematic. It's an "unsigned int" which, due to the nebulousness of C, means its size is only guaranteed to be the "fastest native size available on your processor". Practically speaking, however, unsigned int was 32 bits when BOOL was first #defined by MicroSoft, and will remain 32 bits forever more.

Heh, actually you can probably expect int to always be a DWORD as well, because Intel and MS are both scratching their heads over legacy code on 64-bit processors, and the last I heard had decided to violate the C native/speed directive in favor of word-size compatibility.

*shrug* Maybe you didn't want to know all that. But now you do, anyway. :tongue:

Cheers,

-Chalain
Posted on 2002-04-24 17:19:17 by Chalain
Dunno if 'bool' is always a byte, but at least it is in msvc :].

"fastest native size available on your processor" - that can hold
number of a certain size... otherwise int would probably have been
a byte ;). Anyway, on x86 processor running in 32bit mode, the data
type that fulfills the C standards requirements is a DWORD. A WORD
is large enough, but is slower to work with in 32bit mode.
Posted on 2002-04-25 05:55:57 by f0dder
In 16-bit mode, you could only push/pop 16-bit values. I am relatively sure that in 32-bit mode, you can only push/pop 32-bit values, or at most 16 or 32-bit values. Since parameters passed to the procedure are all pushed on the stack, even if they're byte-sized, a whold dword gets plopped on. Possibly, if you specify a byte-type on the proc, when it gets called you probably would face a movsx eax,bool then push eax so that they would fit on the stack.
Posted on 2002-04-25 18:01:20 by AmkG