All right, newbie question here ;)
I've consulted the MASM documentation and a bunch of other tutorials, etc. but I can't seem to find an answer to exactly what the <> operator means when used in a data declaration.
As I understand it, if you do something like:
And then later on you have:
Then the assembler will automatically replace MAXBYTE with the literal text value between <> to make
So it's basically just a macro of sourts in that context.
But what does a declaration like this mean?
It seems like I only see this used with structs/objects. What exactly does the data get initiailzed to?
I've consulted the MASM documentation and a bunch of other tutorials, etc. but I can't seem to find an answer to exactly what the <> operator means when used in a data declaration.
As I understand it, if you do something like:
.const
MAXBYTE equ <FFh>
And then later on you have:
.code
mov al, MAXBYTE
Then the assembler will automatically replace MAXBYTE with the literal text value between <> to make
.code
mov al, FFh
So it's basically just a macro of sourts in that context.
But what does a declaration like this mean?
.data
complex COMPLEXSTRUCT <>
It seems like I only see this used with structs/objects. What exactly does the data get initiailzed to?
They are used to indicate that the set of values contained are to initialize the structure. <> with nothing in between will initialize it to 0 or the values in the structure definition. Structures work about the same in MASM as in GoAsm, here is the GoAsm explanation :
http://www.jorgon.freeserve.co.uk/GoasmHelp/GoAsm.htm#struc
http://www.jorgon.freeserve.co.uk/GoasmHelp/GoAsm.htm#struc
Ah. Thank you. I knew there was some obvious answer to this. The trouble is, it's hard to do a search on something like < or > because they're special characters that are often ignored or used in the search engine's syntax itself.
So functionally speaking, if I have this structure:
then wouldn't
do the same thing as
Legibility-wise, I'd prefer to use the <> anyway, but I just want to make sure there's not some subtle difference I'm missing.
I think I understand why I never see anyone actually provide a list of values, now. Most win32 structures tend to have a lot of members, including nested structures. Those sound like they'd be confusing to declare using that syntax. It sounds like it's probably best to not do that except with very simple structures (again, from the standpoint of code clarity). Plus they tend to rely on run-time values for most of their members anyway, so it would be pretty pointless.
So functionally speaking, if I have this structure:
RECT STRUCT
left db 0
right db 0
top db 10
bottom db 10
ENDS
then wouldn't
rectangle RECT
do the same thing as
rectangle RECT <>
Legibility-wise, I'd prefer to use the <> anyway, but I just want to make sure there's not some subtle difference I'm missing.
I think I understand why I never see anyone actually provide a list of values, now. Most win32 structures tend to have a lot of members, including nested structures. Those sound like they'd be confusing to declare using that syntax. It sounds like it's probably best to not do that except with very simple structures (again, from the standpoint of code clarity). Plus they tend to rely on run-time values for most of their members anyway, so it would be pretty pointless.
I think in MASM you have to have the <> though it accepts alot of ways...
rect RECT <1,2,3,4> ; rect.left=1,rect.right=2 etc...
rect RECT <1,2,3,4>,<5,6,7,8>,<9,0Ah,0Bh,0Ch> ; three initialized rects
rect RECT <?> ; store as uninitialized
rect RECT <0> ; store initiliaized to 0
rect RECT 16 DUP (<>) ; 16 structures
rect RECT <1,2,3,4> ; rect.left=1,rect.right=2 etc...
rect RECT <1,2,3,4>,<5,6,7,8>,<9,0Ah,0Bh,0Ch> ; three initialized rects
rect RECT <?> ; store as uninitialized
rect RECT <0> ; store initiliaized to 0
rect RECT 16 DUP (<>) ; 16 structures