News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

#DEFINE Question

Started by satpro, July 13, 2015, 03:25:40 AM

Previous topic - Next topic

satpro

I was browsing the GoAsm headers and found this (just a random example):

#DEFINE CHAR DB

...which is understandable.  Then a few lines later was this:

%CHAR STRUCT
    DB
ENDS


My question is:  Are these two related, and if so, why is it (or why would it be) necessary to do this?  Not all defined words are like this.


Also, in C source you often see DWORD, BYTE, etc.  Is it possible to create GoAsm definitions such as:

#DEFINE DWORD DD
#DEFINE WORD DW


...or would it conflict with GoAsm's operation somehow?


Thanks.  I feel like I may have read about this somewhere before but came up empty today (while quickly) looking for it.

Yuri

No, they are not related. Those with a percent sign are used for the types of local variables in procedure frames. If you have defined a type somewhere, e.g.

#define PTR DD

you can't use PTR in a procedure frame. First because simple local types are specified with a single letter (D, Q, etc), and second because such type defines are not recognized by GoAsm for locals, I don't know why. But you can use structures for them. So you can define the pointer type for locals like this:

%PTR STRUCT
    DD
ENDS

Actually it's already defined that way in the headers.

Yes, you can define WORD and DWORD as well.

satpro