MASM32 Downloads
.686p .model flat .codeLen0: cmp ecx,Len2-Len0Len1: org $+100hLen2: Lenx equ (Len1-Len0) if Lenx EQ 6 xor eax,eax else xor ebx,ebx endif end
IF something eq somevalueinclude file1.incELSEinclude file2.incENDIF
.686p .model flat .codeLen0: cmp ecx, Len2-Len0Len1: org $+10hLen2: mov eax , Len1-Len0lenx1 = Len1-Len0if lenx1 EQ 3 xor eax,eax len3 = 1else xor ebx,ebx len3 = 4endifmov eax, len3end Len0
This behavior is mentioned in the Masm 6.1 Readme.txt Span-Dependent Expressions used in Macros -------------------------------------------------- MASM 6.1x evaluates macro expressions only on the first pass of assembly, but code and data are reevaluated on subsequent passes. Because of this, macro expressions which depend on the span between two addresses may not evaluate correctly. For instance, the following code will not evaluate correctly: Label1: JMP Label2 Label2: REPEAT Label2 - Label1 ; Evaluates incorrectly INC AX ENDM
Yep this is definitely expected behaviour, it's just not very smart ..
This work with "org 10" but not with "org 100" ¿?:Code: [Select] .686p .model flat .codeLen0: cmp ecx, Len2-Len0Len1: org $+10hLen2: mov eax , Len1-Len0lenx1 = Len1-Len0if lenx1 EQ 3 xor eax,eax len3 = 1else xor ebx,ebx len3 = 4endifmov eax, len3end Len0
ORG 10 will probably work because the opcode remains in it's 3-byte form instead of needing a DWORD imm value (>byte imm value)