News:

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

Text Constants vs empty array

Started by FromTheSun, April 03, 2007, 06:43:39 AM

Previous topic - Next topic

FromTheSun

When i have a point structure:


POINT  struc
x dd ?
y dd ?
POINT ends


And i want to use it later, does it matter for the assembler whether i use:
pt      POINT {}
pt      POINT {?,?}

Or Text Constants such as?
pt      POINT <>
pt      POINT <?>

hutch--

In MASM notation its like this.


POINT STRUCT
    x dd ?
    y dd ?
POINT ENDS


If you declare it as a LOCAL structure with notation like this,


  LOCAL pt:POINT


You read and write to it like this.


    mov pt.x, eax        ; copy register to memory
    mov pt.y, 1234       ; copy immediate to memory


Numerous API functions take the ADDRESS of a POINT structure as an argument which the API call fills out.

You read them like this.


    mov eax, pt.x
    mov ecx, pt.y
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

FromTheSun

Actually STRUC or STRUCT don't mather:  (source: http://msdn2.microsoft.com/en-us/library/tydf8khh(VS.80).aspx)

But yes, i think it's good habit to capitalize it :) Even though for the assembler it doesnt matter, i even got an error on using Proc as a value because masm32 saw it as a keyword  :eek

I understand the reading and copying of the memory, but what i'm actually asking is, when i got a second struct, using a point struct as a value, such as:


mystruct STRUCT
pt POINT <?>
mystruct ENDS


Does it matter whether i write it like


mystruct STRUCT
pt POINT {}
mystruct ENDS


or


mystruct STRUCT
pt POINT {?,?}
mystruct ENDS


or


mystruct STRUCT
pt POINT <?>
mystruct ENDS


or


mystruct STRUCT
pt POINT <>
mystruct ENDS

PBrennick

FromTheSun,
You could have found your answer by looking for an example in the windows.inc file.


POINT STRUCT
  x  DWORD ?
  y  DWORD ?
POINT ENDS

MSG STRUCT
  hwnd      DWORD      ?
  message   DWORD      ?
  wParam    DWORD      ?
  lParam    DWORD      ?
  time      DWORD      ?
  pt        POINT      <>
MSG ENDS


Okay?

Paul
The GeneSys Project is available from:
The Repository or My crappy website

FromTheSun

huh? i wondered if it mattered, not whether you can use them.. they all assemble without errors..