flat assembler
Message board for the users of flat assembler.

Index > Main > Relative Mov

Author
Thread Post new topic Reply to topic
alwaysnub



Joined: 30 Mar 2013
Posts: 26
alwaysnub 15 Feb 2014, 22:12
The 64-ia-32-architectures software developer manual states that a relative mov can be done, but i cant get fasm to produce it.

Here are the instructions im talking about.

Opcode Instruction
A0 mov al,moffs8
A1 mov ax,moffs16
A2 mov moffs8,al
A3 mov moffs16,ax

What do i need to do?
Post 15 Feb 2014, 22:12
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 15 Feb 2014, 22:48
Code:
mov al, [moffs8]
mov ax, [moffs16]
mov [moffs8], al
mov [moffs16], ax
.
.
.
moffs8  db ?
moffs16 db ?    
Question
Post 15 Feb 2014, 22:48
View user's profile Send private message Reply with quote
alwaysnub



Joined: 30 Mar 2013
Posts: 26
alwaysnub 16 Feb 2014, 00:53
@ LocoDelAssembly

No. That makes the opcodes have an encoding of:

mov r8,r/m8
mov r16,r/m16
mov r/m8,r8
mov r/m16,r16

I need an encoding with moffs. Read the Documentation for the mov instruction.
The 64-ia-32-architectures software developer manual states that moffs is (A simple memory variable (memory offset). The actual address is given by a simple offset relative to the segment base. No ModR/M byte is used in the instruction. The number shown with moffs indicates its size.)
Post 16 Feb 2014, 00:53
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 16 Feb 2014, 01:25
Same source (except I changed one "db" to "dw" and commented the periods), assembled, generated fas file and then ran through listing tool:
Code:
00000000: A0 0C 00                                              mov al, [moffs8]
00000003: A1 0D 00                                              mov ax, [moffs16]
00000006: A2 0C 00                                              mov [moffs8], al
00000009: A3 0D 00                                              mov [moffs16], ax
                                                                ;.
                                                                ;.
                                                                ;.
                                                                moffs8  db ?
                                                                moffs16 dw ?    
Post 16 Feb 2014, 01:25
View user's profile Send private message Reply with quote
alwaysnub



Joined: 30 Mar 2013
Posts: 26
alwaysnub 16 Feb 2014, 01:34
Ok, after retesting, i found that it works if you are using use32 or use16 bit modes, but it does not give me the desired encoding in use64 mode.
Perhaps there's a way to force the moffs encoding in 64-bit mode?
Post 16 Feb 2014, 01:34
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20309
Location: In your JS exploiting you and your system
revolution 16 Feb 2014, 02:17
alwaysnub wrote:
Ok, after retesting, i found that it works if you are using use32 or use16 bit modes, but it does not give me the desired encoding in use64 mode.
Perhaps there's a way to force the moffs encoding in 64-bit mode?
64-bit mode uses RIP relative addressing by default. To ensure an absolute address use the qword override:
Code:
use64
mov al, [qword moffs8]
mov ax, [qword moffs16]
mov [qword moffs8], al
mov [qword moffs16], ax

moffs8  db ?
moffs16 dw ?    
Post 16 Feb 2014, 02:17
View user's profile Send private message Visit poster's website Reply with quote
alwaysnub



Joined: 30 Mar 2013
Posts: 26
alwaysnub 16 Feb 2014, 02:22
Cool, that did it. Thanks guys. Wink
Post 16 Feb 2014, 02:22
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.