flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > dp instruction

Author
Thread Post new topic Reply to topic
FlashBurn



Joined: 06 Jan 2005
Posts: 87
FlashBurn 08 Jan 2005, 11:35
There is something false with this instruction. It saves the values in the wrong order! It seems that it first saves the dword and then the word, but it has to be the other way around!
Post 08 Jan 2005, 11:35
View user's profile Send private message Reply with quote
MCD



Joined: 21 Aug 2004
Posts: 602
Location: Germany
MCD 11 Jan 2005, 10:23
Take a look at Fasm documentation. both the dd and dp instructions in Fasm allow defining data values with a colon, but the data will be stored in a different order as with other assemblers. This is also true for short strings used as numerical constants, like
Code:
mov eax, 'ABCD'    
becomes
Code:
mov eax, 44434241h    
.
Post 11 Jan 2005, 10:23
View user's profile Send private message Reply with quote
FlashBurn



Joined: 06 Jan 2005
Posts: 87
FlashBurn 11 Jan 2005, 13:38
The problem is that I have to use the dp instruction when I want to declare a variable which I then want to load with lidt and lgdt. But I have to use mov instructions to give the variable the right values, but this is overhead I don´t want. Also what other values use the dp instruction? I think this are the only and then there comes first the word and then the dword and not the orher way around! It would be a shame if I have to change the assembler because of this!
Post 11 Jan 2005, 13:38
View user's profile Send private message Reply with quote
beppe85



Joined: 23 Oct 2004
Posts: 181
beppe85 11 Jan 2005, 14:16
To quote "Programmer's Manual":
Quote:
The dp directive and its synonym df accept the values consisting of two numerical expressions separated with colon, the first value will become the high word and the second value will become the low double word of the far pointer value.

There's nothing wrong with this directive, it follows the little-endiam rule.

You can define a macro:

Code:
macro descriptor adword, aword
{
  dd adword
  dw aword
}    
Post 11 Jan 2005, 14:16
View user's profile Send private message Reply with quote
FlashBurn



Joined: 06 Jan 2005
Posts: 87
FlashBurn 11 Jan 2005, 14:26
OK, I solved the problem. I´ve written this:
Code:
GDTR dw limit
         dd base
    

And this code doesn´t work with fasm. But If I write it like this:
Code:
GDTR:
        dw limit
        dd base
    

It will work.

@beppe85

Your macro is also wrong for me, because I need the word before the doubleword!
Post 11 Jan 2005, 14:26
View user's profile Send private message Reply with quote
beppe85



Joined: 23 Oct 2004
Posts: 181
beppe85 11 Jan 2005, 14:31
Yup, I missed that. Just invert the dd/dw.
Post 11 Jan 2005, 14:31
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 12 Jan 2005, 00:10
Code:
label GDTR pword ;maybe it's other size operator, i am not sure
 dw limit 
 dd base
    
Post 12 Jan 2005, 00:10
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number 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-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.