News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Custom types in .data section

Started by Sergiu FUNIERU, March 05, 2010, 03:12:42 AM

Previous topic - Next topic

Sergiu FUNIERU

I try to declare, in the .data section, a variable pdf, of type DATETIME, initialized with 0.
I receive the error : "index.asm(24) : Error A2233: Syntax error: pdt"

What I'm doing wrong?

This is the code:
.686
.model flat, stdcall
option casemap :none 

include \masm32\include\masm32rt.inc
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\gdi32.inc
include \masm32\include\comctl32.inc
include \masm32\include\shell32.inc
include \masm32\include\comdlg32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\comctl32.lib
includelib \masm32\lib\shell32.lib
includelib \masm32\lib\comdlg32.lib

.data
    pdt DATETIME 1 dup (0)

.code
start:
main proc

        ; INVOKE GetLocalDateTime, addr pdt
        ; INVOKE Day, addr pdt

       exit
main endp

end start

jj2007

.data
DATETIME TYPEDEF QWORD    ; A DATETIME is a FILETIME in disguise
pdt DATETIME 1 dup (0)

Sergiu FUNIERU

The code you gave me worked perfectly. Thank you!

I saw that you defined the data type inside the .data section. Is it the same as declaring in an include file? I tried including
include \masm32\datetime\DateTime.inc
instead of defining the type, and it worked, but does it have the same effect on the final code?

Quote from: jj2007 on March 05, 2010, 03:19:31 AMA DATETIME is a FILETIME in disguise
If I try this:
.data
; DATETIME TYPEDEF QWORD    ; A DATETIME is a FILETIME in disguise
pdt FILETIME 1 dup (0)

I receive this error message:
index.asm(25) : Error A2253: Structure improperly initialized: FILETIME
Why?


hutch--

Sergiu,

You have an include file duplication in your post, the masm32rt.inc already has files that you list below it and you are trying to include them twice. Either use it by itself or only add files after it that it does not contain.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

qWord

structs must be initialized using angle brackets:
pdt FILETIME 1 dup (<0>)
FPU in a trice: SmplMath
It's that simple!

Sergiu FUNIERU

Quote from: qWord on March 05, 2010, 03:47:49 AM
structs must be initialized using angle brackets:
pdt FILETIME 1 dup (<0>)
Where did you find the definition of FILETIME? I searched \masm32, and I only found only 1 file that contains the FILETIME word in it.
\masm32\examples\exampl06\jacts\jacts.asm
I searched by this criteria "find all files, no matter the extension, that contain the word FILETIME".

So, am I to understand that FILETIME is a structure of strings, while DATETIME is made of 4 Words in a row? You're using angle brackets, therefore I assume that 0 is a string and not a number. "A DATETIME is a FILETIME in disguise", as mentioned in the file DateTime.chm is just a figure of speech?

GregL

Quote from: SergiuI saw that you defined the data type inside the .data section. Is it the same as declaring in an include file? I tried including
Code:
include \masm32\datetime\DateTime.inc
instead of defining the type, and it worked, but does it have the same effect on the final code?

Yes, it's the same. But, you should use DateTime.inc when using the DateTime library. A DATETIME data type is equivalent to a QWORD. The FILETIME structure is the same size as a QWORD. This is done to avoid having to address the high and low DWORDs of the FILETIME structure.

And like Hutch said try to avoid multiple declarations and definitions, masm32rt.inc is intended to replace several include files. Take a look at masm32rt.inc in a text editor. By the way, DateTime.inc is not included in masm32rt.inc.

Sergiu FUNIERU

Quote from: Greg Lyon on March 05, 2010, 03:59:29 AMAnd like Hutch said try to avoid multiple declarations and definitions, masm32rt.inc is intended to replace several include files. Take a look at masm32rt.inc in a text editor. By the way, DateTime.inc is not included in masm32rt.inc.
My bad. I cleaned the code after he told me so, but I didn't write here the cleaned version.

Everything is clear now, except for the FILETIME.
1. In what file is FILETIME defined?
2. What did you mean by:
QuoteThis is done to avoid having to address the high and low DWORDs of the FILETIME structure.

GregL

Quote from: SergiuSo, am I to understand that FILETIME is a structure of strings, while DATETIME is made of 4 Words in a row?

No, a FILETIME is a structure of 2 DWORDS and a DATETIME is actually a QWORD.  Look up FILETIME on MSDN.  It's defined in windows.inc in masm32.

Quote from: Sergiu"A DATETIME is a FILETIME in disguise", as mentioned in the file DateTime.chm is just a figure of speech?

In the code, it's a comment. In DateTime.chm it's an explanation.


Don't use FILETIME in your code, use DATETIME if you are using the library.

GregL

Quote from: Sergiu2. What did you mean by:
Quote
This is done to avoid having to address the high and low DWORDs of the FILETIME structure.

Using a QWORD instead of a FILETIME is a way of simplifying Date and Time math. 

Look at the code for the DateTime library.

BogdanOntanu

Quote from: Sergiu Funieru on March 05, 2010, 03:55:09 AM
Quote from: qWord on March 05, 2010, 03:47:49 AM
structs must be initialized using angle brackets:
pdt FILETIME 1 dup (<0>)

So, am I to understand that FILETIME is a structure of strings, while DATETIME is made of 4 Words in a row? You're using angle brackets, therefore I assume that 0 is a string and not a number.

NO, you understand WRONGLY.

Structures MUST be initialized by using angle brackets. This is the syntax for initaializing an STRUCT in MASM.

Inside < > you can place initial values to be placed in the structure's fields or "?" for unknown or non initialized fields. They are to be considered as numbers or strings or STRUCT's or typedefs or whatever other types depending on the STRUCT definition.
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro