Hi!

I am rather new to MASM32 and my general experience with it this far is nothing but good. I am having a small problem in understanding the variable types that exists in MASM32 (or Assembly at all)? I know about BYTE and DWORD, but is there any variable type which equals C's "char"? I need this to translate the following C lines:

char* item[32];
char* value[32];

While I am at it, could some Assembly/C guru help me out with translating the following code to Assembly?

typedef struct
{
  condition (*close)(void* instance);
  sInt32 (*read)(void* instance,void* destBuffer,uInt32 count);
  condition (*eof)(void* instance);
  condition (*seekable)(void* instance);
  sInt64 (*length)(void* instance);
  sInt64 (*getPos)(void* instance);
  condition (*seek)(void* instance,sInt64 pos);
}
#if defined(__GNUC__)
__attribute__((packed))
#endif
ReadInterface;

This is a structure for a callback system in C.

Thanks in advance guys!

Regards,
Seb

Edit: Typo.
Posted on 2005-03-21 16:09:21 by Seb
Seb,

My C is very rusty but I think you can emulate,


char* item[32];
char* value[32];


With,


LOCAL item[32]:BYTE
LOCAL value[32]:BYTE
Posted on 2005-03-21 20:39:08 by hutch--
That's almost entirely correct except in C the variable "item" is a pointer but in MASM "item" is actualy the first byte in the sequence.  In C where you would use just "item" you'll have to use "ADDR item" in MASM.

BYTE:: char, bool
WORD:: not really used in C, unicode character
DWORD:: integer data (both signed and unsigned), all pointer types, and many windows data types (HANDLES, HWND, MSG, etc)
QWORD:: int64

Spara
Posted on 2005-03-21 20:49:44 by Sparafusile
char* item[32] is an array of character pointers, so it is 32 DWORDs. (The * makes it a pointer.)

The ReadInterface structure contains only function pointers.
For example...

sInt32 (*read)(void* instance,void* destBuffer,uInt32 count);

is a function pointer named "read". The referenced function (which is not named "read") returns an sInt32 value. And it has three arguments.
Posted on 2005-03-22 03:04:28 by tenkey
Thanks guys! :-D I think I got it now.

Regards,
Seb
Posted on 2005-03-22 03:51:09 by Seb
Hi guys!

I am having another small question to ask... what would a "char**" be in Assembly? Also, when dealing with structures in Assembly (such as the "ReadInterface" structure), would I have to declare it as a pointer (DWORD)?

Thanks!

Regards,
Seb
Posted on 2005-03-22 04:40:38 by Seb
A char is a byte or array of bytes. In masm this is dataype BYTE.
* indicates a pointer.
** indicates a pointer to a pointer.

Therefore, char** is a pointer to a stringpointer, ie, the address where a stringpointer has been stored.

Posted on 2005-03-22 05:32:31 by Homer

A char is a byte or array of bytes. In masm this is dataype BYTE.
* indicates a pointer.
** indicates a pointer to a pointer.

Therefore, char** is a pointer to a stringpointer, ie, the address where a stringpointer has been stored.




Yes, but how would I declare it in Assembly?

variable DB ?
Posted on 2005-03-22 06:57:24 by Seb
variable dd ?

Pointers are usually dword.
Posted on 2005-03-22 07:31:27 by roticv
Oh, yes, that's correct.
Posted on 2005-03-22 07:51:06 by Seb