flat assembler
Message board for the users of flat assembler.

Index > Main > A bug on lgdt code generation?

Author
Thread Post new topic Reply to topic
humeafo



Joined: 12 Mar 2010
Posts: 3
humeafo 12 Mar 2010, 01:23
my dos program 16-bit segment code:

lgdt fword [gdtr_]

seems generate the 66 prefix, while this is not necessary according to intel manual?
Post 12 Mar 2010, 01:23
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20623
Location: In your JS exploiting you and your system
revolution 12 Mar 2010, 01:46
Intel Manual wrote:
If operand-size attribute is 32 bits, a 16-bit limit (lower 2 bytes of the 6-byte data operand) and a 32-bit base address (upper 4 bytes of the data operand) are loaded into the register. If the operand-size attribute is 16 bits, a 16-bit limit (lower 2 bytes) and a 24-bit base address (third, fourth, and fifth byte) are loaded. Here, the high-order byte of the operand is not used and the high-order byte of the base address in the GDTR or IDTR is filled with zeros.
Post 12 Mar 2010, 01:46
View user's profile Send private message Visit poster's website Reply with quote
humeafo



Joined: 12 Mar 2010
Posts: 3
humeafo 12 Mar 2010, 01:51
yes, you're right. I misunderstand the meaning on my fist glance of the manual.
So fasm 1.50 generated the wrong code without 66h while not fasm 1.69.
Post 12 Mar 2010, 01:51
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 12 Mar 2010, 01:53
Another source of info:

Intel® 64 and IA-32 Architectures Software Developer’s Manual Volume 3A
- 9.10 INITIALIZATION AND MODE SWITCHING EXAMPLE
-- 9.10.2 STARTUP.ASM Listing
Code:
.
.
.
171 DB 66H; execute a 32 bit LGDT
172 LGDT TEMP_GDT_scratch    


If you remove "fword" the prefix will not be generated, but keep in mind revolution's post.
Post 12 Mar 2010, 01:53
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20623
Location: In your JS exploiting you and your system
revolution 12 Mar 2010, 01:54
If you don't need the 0x66 prefix and want a 24bt base address then just use this:
Code:
gdtr_: df 0x123456
;...
lgdt [gdtr_]    
Post 12 Mar 2010, 01:54
View user's profile Send private message Visit poster's website Reply with quote
humeafo



Joined: 12 Mar 2010
Posts: 3
humeafo 12 Mar 2010, 01:58
thanks, problem solved.
Post 12 Mar 2010, 01:58
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20623
Location: In your JS exploiting you and your system
revolution 12 Mar 2010, 03:44
LocoDelAssembly wrote:
If you remove "fword" the prefix will not be generated ...
You also have to make sure the variable definition for gdtr_ is not an fword type, hence the colon (:) after the variable name in my post above.
Post 12 Mar 2010, 03:44
View user's profile Send private message Visit poster's website 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.