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: 339
Location: Asia, Singapore
sid123 27 Oct 2013, 05:04
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: 3499
Location: Bulgaria
JohnFound 27 Oct 2013, 05:09
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: 339
Location: Asia, Singapore
sid123 27 Oct 2013, 05:10
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: 618
cod3b453 27 Oct 2013, 10:46
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: 517
Location: Munich
shutdownall 27 Oct 2013, 11:51
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: 20451
Location: In your JS exploiting you and your system
revolution 27 Oct 2013, 14:39
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: 517
Location: Munich
shutdownall 27 Oct 2013, 16:30
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: 339
Location: Asia, Singapore
sid123 28 Oct 2013, 09:53
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.