Code:
%define x 0x03
x equ 0x03
What’s the difference between them?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
%defineis a far more powerful way of doing macros, akin to the C pre-processor. In your simplistic case, there is not a lot of difference, usingxin the source code will result in the constant3being substituted. There’s a subtle difference in thatequstatements are evaluated once, when they are first read and%definemacros are evaluated whenever they are encountered in the source.You can see the difference there between the two statement snippets:
In that case,
addr, when encountered in the code, will have different values. In the first case,$will be the location of the assembly position at the place where theequis. In other words, where it’s defined.In the second case, it evaluates to the assembly location at the place where
addris used.Where
%defineshines is with something like:or:
(or even considerably more complex things) which allow you to pass parameters to your macro, something not possible with a simple
equ.