News:

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

Warnings from ML.exe using DateTime struct

Started by Rsir, July 12, 2009, 10:58:22 AM

Previous topic - Next topic

Rsir

Hi Forum,
I am working on a program that calculates the time of sunrise and sunset
at a given GPS (place) and a given date.
Just for fun and to learn better programming in assembler.
Years ago a made a working version in Turbo-C.
Using the 'DateTime.lib' from Greg Lyon 2007 Version 1.3.
Using default settings of Ketil's RadASM

Despite I only just begin with this prg. I already feel disturbed by warnings I can not correct.
Anybody who can tell me where I have to put the declarations of DateTime-variables?
Or what else went wrong?


;-Sun.inc------------
.
.
.data
pi                  dq   3.14159265    ;pi
pi2                 dq   6.28318531    ;pi*2
DR                  dq   0.01745329    ;pi/180
K1                  dq   0.27943917    ;pi/180*15*1.067379
Z1                  dq   1.58533492    ;pi/180*90.833

ALIGN 8
;pdtStdTime         DATETIME     <>
;pdtLocTime         DATETIME     <>

.data?          ;BSS segment?

hInstance           dd ?
CommandLine         dd ?
hWnd                dd ?
hIcon               dd ?
ALIGN 8
pdtStdTime          DATETIME     <>
pdtLocTime          DATETIME     <>
pstStdTime           SYSTEMTIME   <>
pstLocTime           SYSTEMTIME   <>
.
.
;---------------

Quote
---------------
C:\Masm32\Bin\ML.EXE /c /coff /Cp /nologo /I"C:\Masm32\Include" "sun.asm"
Assembling: sun.asm
sun.inc(79) : warning A4014: instructions and initialized data not supported in BSS segments
sun.inc(80) : warning A4014: instructions and initialized data not supported in BSS segments

C:\Masm32\Bin\LINK.EXE /SUBSYSTEM:WINDOWS /RELEASE /VERSION:4.0 /LIBPATH:"C:\Masm32\Lib" /OUT:"sun.exe" "sun.obj" "sun.res"
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

Executing:
"C:\RadASM\Masm\Projects\sun\sun.exe"

Make finished.
Total compile time 2168 ms
-----------------

Rsir

dedndave

in the ".DATA?" segment, you are not allowed to have initialized data
if you want to initialize it, put it in ".DATA"
otherwise, use the "?" operator to define values
tell us which lines are 79 and 80 in the source file - that may help fix the error
i don't see where you have violated the rule

.data
db 0

.data
db ?

the unitialized define will likely be a 0, but no guarantees
uninitialized data does not show up in the size of the exe file - initialized data will, of course

cool app, though
i am a ham radio operator
we use the "grey-line" to pick optimal times to communicate to a particular place on the globe
for example, if i want to talk from the US to England on 7 Mhz, the best time is at their sunrise/sunset
optimal is if i can get a grey-line at both locations
if you google "grey-line", "gray-line", etc, you may find several similar apps for ideas

Rsir

Hi dedndave,
thanks for replying.

     ;-Sun.inc------------
     .
     .
     .data
     pi                  dq   3.14159265    ;pi
     pi2                 dq   6.28318531    ;pi*2
     DR                  dq   0.01745329    ;pi/180
     K1                  dq   0.27943917    ;pi/180*15*1.067379
     Z1                  dq   1.58533492    ;pi/180*90.833

     ALIGN 8
69  pdtStdTime         DATETIME     <>
70  pdtLocTime         DATETIME     <>

     .data?          ;BSS segment?

     hInstance           dd ?
     CommandLine         dd ?
     hWnd                dd ?
     hIcon               dd ?
78  ALIGN 8
79  ;pdtStdTime         DATETIME     <>
80  ;pdtLocTime         DATETIME     <>
81  pstStdTime           SYSTEMTIME   <>
    pstLocTime           SYSTEMTIME   <>
     .
     .
     ;---------------

When I put the declaration of DateTime structs in the .DATA segment I get the following error:

QuoteC:\Masm32\Bin\ML.EXE /c /coff /Cp /nologo /I"C:\Masm32\Include" "sun.asm"
Assembling: sun.asm
sun.inc(69) : error A2167: unexpected literal found in expression
sun.inc(70) : error A2167: unexpected literal found in expression

Make error(s) occured.
Total compile time 1482 ms

Do you know how to initialize in the .DATA those DateTime struct?
Is there a way to preserve the tabs in a piece of text copied in a code.block in this forum's editor?

Nice to know that my project already has a future user...

Rsir

dedndave

well - i think the line numbers generated that error - lol
the time structures should be defined in masm32\include\windows.inc

i find the SYSTEMTIME structure definition in that file:

SYSTEMTIME STRUCT
  wYear             WORD      ?
  wMonth            WORD      ?
  wDayOfWeek        WORD      ?
  wDay              WORD      ?
  wHour             WORD      ?
  wMinute           WORD      ?
  wSecond           WORD      ?
  wMilliseconds     WORD      ?
SYSTEMTIME ENDS

i do not see a DATETIME structure defined, however
so that is part of your problem
there are a few others - FILEDATETIME - and a few having to do with the daylight savings time change
you may define the structure in your file, and the one in windows.inc will be ignored
that is one way to define it with initialized data
the other way would be to define it as uninitialized data, then initialize it with code, such as an API function, or with mov's

Rsir

The author of the DateTime.lib wrote:

QuoteDateTime Library

Version 1.3
Greg Lyon  2007

A DATETIME is a FILETIME in disguise. It is defined as DATETIME TYPEDEF QWORD. The minimum valid DATETIME is
January 1, 1601 12:00:00 AM. The maximum valid DATETIME is December 31, 30827 12:59:59 PM. DATETIME
variables should be 8-byte aligned, use ALIGN 8.


Your help made me try:
    .DATA
     ALIGN 8
69  pdtStdTime         DATETIME     0h
70  pdtLocTime         DATETIME     0h
.
.

and that seems to solve the problem.
thanks again for your help
regards, Rsir

Rsir

also, if declared in the .DATA? part

.DATA?
ALIGN 8
pdtStdTime         DATETIME     ?
pdtLocTime         DATETIME     ?


will do the job.
It must be the '<>' thing for structures that fools us. don't you think?
Rsir

dedndave

well - he has told you it is a qword
i tend to simplify an already complicated world, whenever possible...

        .DATA?
        ALIGN 8
pdtStdTime dq ?
pdtLocTime dq ?

or

        .DATA?
        ALIGN 8
pdtStdTime dd ?,?
pdtLocTime dd ?,?

i might prefer the later, if i will be accessing the values with dword sized registers
for an API or LIB function, you are passing a pointer, so it doesn't care what the type is

also, he may have provided an inc file with his library
he has probably defined the DATETIME struct in that file
you may want to INCLUDE that file at the beginning of your program so that you may access his definitions
if his library was intended for use with C, it will have a ".h" file, instead of a ".inc"
if that is the case, you may d/l this file and use the h2inc translator to create an inc file usable with masm
http://download.microsoft.com/download/vb60ent/Update/6/W9X2KXP/EN-US/vcpp5.exe
there are other sources for h2inc translators - i can't locate the links at the moment - lol

GregL

Rsir,

You've got it, a DATETIME is a QWORD, not a structure. The angle brackets won't work.


dedndave,

The DATETIME library is included in the masm32 package.