Defines

Defines are a way to customize and improve your Doukutsu assembler experience.
To use them, you'll need a define block, which starts with #define and ends with #enddefine.
offset 405F30

#define
// Define macros go here.
#enddefine

//code goes here.
A define in the form:
foo=bar
will replace all instances of foo with the replacement bar in your assembly-source-code before parsing of the actual code begins.

New Instructions

If there's an instruction or a variation of an instruction that the Doukutsu Assembler doesn't support, you can still use that instruction by taking advantage of defines.

Let's say that you happen to love using the instruction IN AL,DX. The problem is, most people don't use IN AL,DX on a regular basis, so it's not supported. You can still use a define to get around this:
offset 00488318

#define
IN AL,DX=data EC
#enddefine

IN AL,DX
CMP AL,1
JNE 475000
RETN
You can use OllyDbg or an assembly reference to figure out that IN AL,DX has the hexcode 0xEC, so just use the define IN AL,DX=data EC to replace all instances of IN AL,DX with the hex value EC.

In the past, comments were not allowed in the defines block. This isn't true anymore. Go ahead and put comments in the #define/#enddefine block.

Naming Your Variables

Wouldn't it be nice if you could refer to DWORD PTR DS:[49E6D0] with the name MaxHealth? Well, now you can.

Take a look at the following code that uses defined variables:
offset 415000

#define
npc.xvel=[EDX+10]
npc.yvel=[EDX+14]
quote.x=[49E654]
quote.y=[49E658]
npc.xpos=[EDX+8]
npc.ypos=[EDX+C]
npc.direction=[EDX+4C]
setpointer=MOV EDX,[EBP+8]
#enddefine

setpointer
MOV EAX,quote.x
CMP EAX,npc.xpos
JGE :approach_from_right
MOV npc.xvel,400
MOV npc.direction,2
JMP :else1
:approach_from_right
MOV npc.xvel,-400
MOV npc.direction,0
:else1
MOV EAX,npc.xvel
ADD npc.xpos,EAX
MOV EAX,npc.yvel
ADD npc.ypos,EAX
File: defines.txt

The file defines.txt is the global defines file. You can add more to this file if you want. All defines in defines.txt are always used by the Doukutsu Assembler in addition to anything in the #define/#enddefine block that you specify.

You'll notice that jump synonyms, conditional-move synonyms, set-byte synonyms, the SAL instruction, and any MOV EIP,(whatever) instructions are already located inside defines.txt:
jpe=jp
jpo=jnp
jz=je
jnz=jne
jnl=jge
jnle=jg
jnge=jl
jng=jle
jnbe=ja
jnae=jb
jc=jb
jna=jbe
jnc=jnb
jae=jnb
mov eip,="jmp "

sal=shl

cmovpe=cmovp
cmovpo=cmovnp
cmovz=cmove
cmovnz=cmovne
cmovnl=cmovge
cmovnle=cmovg
cmovnge=cmovl
cmovng=cmovle
cmovnbe=cmova
cmovnae=cmovb
cmovc=cmovb
cmovna=cmovbe
cmovnc=cmovnb
cmovae=cmovnb

setpe=setp
setpo=setnp
setz=sete
setnz=setne
setnl=setge
setnle=setg
setnge=setl
setng=setle
setnbe=seta
setnae=setb
setc=setb
setna=setbe
setnc=setnb
setae=setnb
If you're using an old custom defines list, you may want to update your list with these new default defines.

Note: comments are now allowed in defines.txt as well.

Quoted Define Values
Some characters such as the pipe character are automatically removed in defines.
If you want to use them, please see the Quoted Defines Guide.


Table of Contents