Author Topic: #DEFINE Question  (Read 2111 times)

satpro

  • Member
  • **
  • Posts: 116
#DEFINE Question
« on: July 13, 2015, 03:25:40 AM »
I was browsing the GoAsm headers and found this (just a random example):

Code: [Select]
#DEFINE CHAR DB
...which is understandable.  Then a few lines later was this:

Code: [Select]
%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:

Code: [Select]
#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

  • Member
  • **
  • Posts: 175
Re: #DEFINE Question
« Reply #1 on: July 13, 2015, 04:26:46 AM »
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.
Code: [Select]
#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:
Code: [Select]
%PTR STRUCT
    DD
ENDS
Actually it's already defined that way in the headers.

Yes, you can define WORD and DWORD as well.

satpro

  • Member
  • **
  • Posts: 116
Re: #DEFINE Question
« Reply #2 on: July 13, 2015, 05:47:57 AM »
Thanks a bunch, Yuri!