flat assembler
Message board for the users of flat assembler.

Index > Main > MOV DL,[DH+1] Doesn't wok? :P

Author
Thread Post new topic Reply to topic
sid123



Joined: 30 Jul 2013
Posts: 340
Location: Asia, Singapore
sid123
Alright I agree I am a pure noob in ASM,
When I try this code it says "Invalid Operand Address","Invalid Operand"
Code:
MOV DL,[DH + 1]
    

What I wanted to simply do is assign the value of DH + 1, to DL,
Note: DH needs to be preserved before calling the function, so I can't use :
Code:
INC DH ; This would destroy the current value of DH
    

lol I know this is one of the WORST questions EVER!
But I can't get my code work![/code]

_________________
"Those who can make you believe in absurdities can make you commit atrocities" -- Voltaire https://github.com/Benderx2/R3X
XD
Post 27 Oct 2013, 05:04
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
Everything closed in square brackets is address. But x86 can't use 8bit registers as address. You need to
Code:
mov  dl, dh
inc  dl    
Note that if it was 32bit register you could do:
Code:
lea  ecx, [edx+1]    
because 32bit addresses are valid.
Post 27 Oct 2013, 05:09
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
sid123



Joined: 30 Jul 2013
Posts: 340
Location: Asia, Singapore
sid123
Why didn't I think about that? That's common sense. I guess my question was pretty lame. Thanks!
Post 27 Oct 2013, 05:10
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
A useful reference is http://ref.x86asm.net/coder32-abc.html#modrm_byte_16 which shows the valid effective addresses in 16bit; note that the only registers you can use are bx/si/di/bp. (This is somethign that gets me every time I change my boot loader because I'm used to 64bit code Laughing )
Post 27 Oct 2013, 10:46
View user's profile Send private message Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
Helpful are the instructions

MOVZX
MOVSX

as well. MOVZX will clear the upper part of a register when transferring the lower part.

Like MOVZX CX,DL which is a combination of

XOR CX,CX
MOV CL,DL
Post 27 Oct 2013, 11:51
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
shutdownall wrote:
Like MOVZX CX,DL which is a combination of

XOR CX,CX
MOV CL,DL
Not precisely because MOVZX does not alter the flags, whereas XOR does.
Post 27 Oct 2013, 14:39
View user's profile Send private message Visit poster's website Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
Okay, lets write:

MOV CH,0
MOV CL,DL

Cool
Post 27 Oct 2013, 16:30
View user's profile Send private message Send e-mail Reply with quote
sid123



Joined: 30 Jul 2013
Posts: 340
Location: Asia, Singapore
sid123
Also I have one more question, How would I do this :
MOV SI,AL?
Post 28 Oct 2013, 09:53
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.

Powered by rwasa.