Quoted Defines

(If you have not done so, please read the regular defines guide first.)

You can now use quoted values in defines. For example, the following two defines are equivalent:
alpha=beta
"alpha" = "beta"
Generally, you should try to avoid quotes whenever possible because they cause your code to be assembled more slowly. However, there are some advantages to using quoted values.

Using Special Characters
You can use quotes to insert special characters into define entries that would otherwise be ignored or interpreted incorrectly. For example, pipe characters | are normally ignored in defines. But if you put quotes into your defines, they will not be ignored:
offset 4620AA

#define
/* 0x11 = 17 in base 10. */
run_TSC_Event(17)="PUSH 11 | CALL 00421990 | ADD ESP,4"
#enddefine

run_TSC_Event(17)    ;Refill player's health/missiles.
Remember that pipes are used to write multiple commands on the same line. In this case, the define macro will replace run_TSC_Event(17) with PUSH 11 | CALL 00421990 | ADD ESP,4. Without the quotes, the pipes will be ignored and you'll get a syntax error.

You can also do other interesting things like put equal signs into your defines.
offset 450498

#define
"eax = 0"= XOR eax,eax
"eax = "= MOV eax,
"eax += "= ADD eax,
eax++= INC eax
#enddefine

eax = 0      ;Set EAX to zero using bitwise XOR.
eax = 24     ;Gets converted to MOV EAX,24.
eax += 500   ;Adds 0x500 to EAX.
eax++        ;Increases EAX by 1.
Now we have turned x86 assembly into a language that more resembles C or C++.
However, you still have to be careful about spacing. eax = 0 will work because there is one space of padding on each side of the equals sign, just as you specified in your defines. But eax=0 will not work because the space of padding is gone, and so the program can't replace the unrecognized statement.

Using Escape Characters
Escape characters are special sequences of characters that are interpreted differently than regular characters. They are a way to encode certain characters inside a quoted define value that would otherwise be impossible to represent. For instance, you can use actual quotes inside of quoted values by using escape characters.

The list of escape characters are as follows:
Escape SequenceGets Converted To
\""
\\\
\//
\semi;

Here's a way to insert a text string into your code using quoted defines. Here I've highlighted the escape sequences in red for easier readability.
offset 460C00

#define
"string \"Config.dat\""=data 43 6f 6e 66 69 67 2e 64 61 74 00
#enddefine

string "Config.dat"
Keeping Leading and Trailing Spaces
Normally, leading and trailing spaces for each leftside and rightside entry of each define are removed. This is a bit hard to explain, so I'll illustrate with a diagram:

How Defines Remove Spaces

Sorry about the ugliness of the above picture. Anyway, what should you do if you want to preserve some leading or trailing spaces? Easy. You put the spaces in quotes.

For example, quoted defines are used once in the global file defines.txt: mov eip,="jmp ". This ensures that if you do something like MOV EIP,401000 it will get converted to the correct statement JMP 401000 with a space between the JMP and the address.

Table of Contents