flat assembler
Message board for the users of flat assembler.

Index > Main > Improper Opcode for flat binary file

Author
Thread Post new topic Reply to topic
TightCoderEx



Joined: 14 Feb 2013
Posts: 58
Location: Alberta
TightCoderEx
When I compile this
Code:
        use64
        org     0x100000

        mov     edi, [Toolc]

   Toolc:        dw      32    
I get this;

8B 3D 00 00 00 00 mov edi, [rel 0x6]

where what I want is this

8B 3C 25 07 00 10 00 mov edi, [0x100007]

What am I doing wrong?
Post 24 Jul 2013, 02:11
View user's profile Send private message Visit poster's website Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 730
tthsqe
8B 3D 00 00 00 00 is correct for the code that you posted. I'm quite sure that in long mode direct memory references are RIP relative from the next instruction.

There might be some some encoding of mov eax,[blah blah] that are not relative to RIP but I was never able to deduce this from the documentation.
Post 24 Jul 2013, 03:24
View user's profile Send private message Reply with quote
TightCoderEx



Joined: 14 Feb 2013
Posts: 58
Location: Alberta
TightCoderEx
Even though the first scenario is the better alternative albeit 1 byte, but I didn't expect to see position independence mixed with absolute like 0C compared to 07
Code:
00000007  BB78001000        mov ebx,0x100078
0000000C  488B3D3D000000    mov rdi,[rel 0x50]
00000013  488B7510          mov rsi,[rbp+0x10]    
The other problem was the error that spawned this question had nothing to do with the assembly, but rather the way I mix 32 with 64 and one of my pointers had extraneous values in the high order 32 bits.

Anyway, problem solved, thanks
Post 24 Jul 2013, 07:50
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc
TightCoderEx
You can force absolute addressing by putting a size operator into the brackets:
Code:
mov edi,[qword Toolc]    

_________________
Faith is a superposition of knowledge and fallacy
Post 24 Jul 2013, 19:49
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.