flat assembler
Message board for the users of flat assembler.

 Index > Macroinstructions > invalid value in relativeto operator [solved]
Author
CandyMan

Joined: 04 Sep 2009
Posts: 380
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
CandyMan 29 Jan 2015, 22:05
Code:
```macro   lea     Dst,Src
{
if Src eqtype [0] & Src relativeto \$    ;error: invalid value
if Dst eq rax
lea     eax,Src
else if Dst eq rbx
lea     ebx,Src
else if Dst eq rcx
lea     ecx,Src
else if Dst eq rdx
lea     edx,Src
else if Dst eq rsi
lea     esi,Src
else if Dst eq rdi
lea     edi,Src
else if Dst eq rbp
lea     ebp,Src
else if Dst eq rsp
lea     esp,Src
else if Dst eq r8
lea     r8d,Src
else if Dst eq r9
lea     r9d,Src
else if Dst eq r10
lea     r10d,Src
else if Dst eq r11
lea     r11d,Src
else if Dst eq r12
lea     r12d,Src
else if Dst eq r13
lea     r13d,Src
else if Dst eq r14
lea     r14d,Src
else if Dst eq r15
lea     r15d,Src
else
lea     Dst,Src
end if
else
lea     Dst,Src
end if
}

use64
org     0

lea     rax,[Z]         ;change rax to eax
lea     rax,[rdi+rcx*8] ;not change rax to eax

Z:
```

_________________
smaller is better

Last edited by CandyMan on 30 Jan 2015, 15:21; edited 1 time in total
29 Jan 2015, 22:05
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 19076
revolution 29 Jan 2015, 22:13
TFM wrote:
With relativeto operator it is possible to check whether values of two expressions differ only by constant amount. The valid syntax is a numerical expression followed by relativeto and then another expression (possibly register-based). Labels that have no simple numerical value can be tested this way to determine what kind of operations may be possible with them.
So "[addr] relativeto value" is not valid. You'll need to remove the surrounding brackets to to a test like that.
29 Jan 2015, 22:13
CandyMan

Joined: 04 Sep 2009
Posts: 380
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
CandyMan 30 Jan 2015, 15:19
Code:
```macro   lea     Dst,Src
{
local ..Word
virtual at 0
mov     eax,Src
end virtual
if Src eqtype [0] & ..Word=0x058B
if Dst eq rax
lea     eax,Src
else if Dst eq rbx
lea     ebx,Src
else if Dst eq rcx
lea     ecx,Src
else if Dst eq rdx
lea     edx,Src
else if Dst eq rsi
lea     esi,Src
else if Dst eq rdi
lea     edi,Src
else if Dst eq rbp
lea     ebp,Src
else if Dst eq rsp
lea     esp,Src
else if Dst eq r8
lea     r8d,Src
else if Dst eq r9
lea     r9d,Src
else if Dst eq r10
lea     r10d,Src
else if Dst eq r11
lea     r11d,Src
else if Dst eq r12
lea     r12d,Src
else if Dst eq r13
lea     r13d,Src
else if Dst eq r14
lea     r14d,Src
else if Dst eq r15
lea     r15d,Src
else
lea     Dst,Src
end if
else
lea     Dst,Src
end if
}

use64
lea     rax,[Z]
lea     rax,[rdi+rcx*8]
Z:
```

_________________
smaller is better
30 Jan 2015, 15:19
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum